/* ======= Base & Theme (Medical) ======= */
:root {
    --primary: #0b5ed7;
    --primary-dark: #0a4db0;
    --secondary: #10b981;
    --secondary-dark: #0f9f7a;
    --accent: #38bdf8;
    --accent-soft: #e0f2fe;
    --danger: #ef4444;
    --bg: #f6f9fc;
    --bg-2: #eef5ff;
    --panel: #ffffff;
    --panel-soft: #f8fbff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(900px 600px at 0% 0%, #e9f3ff 0%, transparent 60%),
                radial-gradient(800px 500px at 100% 0%, #e6fffb 0%, transparent 55%),
                var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* LAYOUT */
.layout { display: flex; height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: 290px;
    background: linear-gradient(180deg, #0b5ed7 0%, #0b4bb3 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.6rem;
    position: relative;
    box-shadow: 10px 0 30px rgba(11, 94, 215, 0.15);
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 1rem; margin-bottom: 3rem; }
.logo-icon {
    width: 46px; height: 46px;
    background: #ffffff;
    color: var(--primary);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}
.logo-text { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.5px; }
.logo-text span { color: #a7f3d0; }

.menu { display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.menu a {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.9rem 1rem;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    border-radius: 14px;
    transition: 0.25s ease;
    font-weight: 600;
    border: 1px solid transparent;
}
.menu a:hover, .menu a.active {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateX(4px);
}
.menu i { width: 20px; text-align: center; }

.user-card {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
}
.avatar {
    width: 42px; height: 42px;
    background: #ffffff;
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

/* MAIN CONTENT */
.content { flex: 1; padding: 2.2rem 3rem; overflow-y: auto; }

.top-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2.2rem;
}
.titles h1 { font-size: 2.2rem; font-weight: 700; color: var(--primary); }
.titles p { color: var(--muted); margin-top: 6px; }

.status-badge {
    padding: 0.55rem 1rem;
    background: #e9fef7;
    color: var(--secondary);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    display: flex; align-items: center; gap: 8px;
    border: 1px solid #c7f9ea;
}

.workspace {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2rem;
    height: calc(100vh - 170px);
}

/* PANELS */
.panel {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    border: 1px solid var(--border);
}

.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.panel-header h3 { font-size: 1.05rem; color: var(--primary); font-weight: 700; }

.actions { display: flex; gap: 0.5rem; }
.icon-btn {
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--primary);
    width: 40px; height: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s ease;
}
.icon-btn:hover { background: #e9f3ff; border-color: #cfe3ff; }

/* MICROPHONE */
.recording-panel { align-items: center; justify-content: center; text-align: center; position: relative; overflow: hidden; }
.mic-container { position: relative; width: 130px; height: 130px; display: flex; align-items: center; justify-content: center; margin: 2rem 0; }
.mic-button {
    width: 86px; height: 86px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.9rem;
    cursor: pointer;
    z-index: 2;
    transition: 0.25s ease;
    box-shadow: 0 15px 35px rgba(11, 94, 215, 0.25);
}
.mic-button:hover { transform: scale(1.06); }

.recording .mic-button { background: linear-gradient(135deg, #fb7185, #ef4444); box-shadow: 0 15px 35px rgba(239, 68, 68, 0.35); }
.pulse-ring {
    position: absolute; width: 100%; height: 100%;
    border-radius: 50%; border: 2px solid rgba(11, 94, 215, 0.35);
    opacity: 0; transform: scale(0.8);
}
.recording .pulse-ring { animation: pulse 2s infinite; }
.recording .pulse-ring.delay { animation-delay: 0.5s; }

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 0.6; }
    100% { transform: scale(2.1); opacity: 0; }
}

.status-message {
    font-weight: 600; color: var(--muted);
    margin-top: 1rem; min-height: 24px;
}

/* ASSISTANT */
.assist-panel { background: #f7fbff; border: 1px solid #e1f0ff; }
.badge-assist {
    background: #e8f0ff;
    color: #1d4ed8;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}
.badge-assist.blue { background: #e0f2fe; color: #0369a1; }
.alert-banner {
    background: #fff1f2;
    color: #be123c;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 1px solid #fecdd3;
}

/* ÉDITEUR */
.result-panel { position: relative; }
.editor-container { flex: 1; position: relative; }
textarea {
    width: 100%; height: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    resize: none;
    font-family: 'Outfit', sans-serif; font-size: 1.05rem; line-height: 1.7;
    color: var(--text); outline: none;
    background: var(--panel-soft);
    padding: 1rem 1.2rem;
}
textarea::placeholder { color: #94a3b8; }

.panel-footer { display: flex; gap: 14px; margin-top: 1.2rem; }

.btn-primary, .btn-secondary, .btn-success {
    padding: 1rem 1.1rem;
    border: none; border-radius: 16px;
    font-size: 1rem; font-weight: 700; font-family: 'Outfit', sans-serif;
    cursor: pointer; transition: 0.25s ease;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--secondary), #34d399);
    color: #0b1220;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.25);
}
.btn-primary:disabled { background: #e2e8f0; color: #94a3b8; box-shadow: none; cursor: not-allowed; }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }

.btn-secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e2e8f0; border-color: #cbd5e1; }

.btn-success {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: #fff;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
}
.btn-success:hover { transform: translateY(-2px); }

/* MODAL */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.glass-effect {
    background: #ffffff;
    padding: 2.5rem; border-radius: 26px;
    width: 640px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.modal-header { display: flex; justify-content: space-between; margin-bottom: 1.8rem; align-items: center; }
.modal-header h2 { color: var(--primary); font-size: 1.4rem; }
.close-icon { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); transition: 0.2s; }
.close-icon:hover { color: var(--danger); transform: rotate(90deg); }

.input-group { margin-bottom: 1.2rem; }
.input-group label {
    display: block; margin-bottom: 0.6rem; font-weight: 700; font-size: 0.8rem;
    color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px;
}
.input-wrapper, .textarea-wrapper {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px; padding: 1rem;
    display: flex; align-items: center; gap: 0.8rem;
    transition: 0.2s;
}
.input-wrapper:focus-within, .textarea-wrapper:focus-within {
    border-color: #bfdbfe;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
.input-wrapper input {
    border: none; background: transparent; width: 100%; font-size: 1rem; font-weight: 600; color: var(--text); outline: none;
}
.input-wrapper i { color: var(--primary); }
.textarea-wrapper textarea { height: 160px; font-size: 0.95rem; }

/* ======= Historique ======= */
.controls-container {
    background: var(--panel);
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
}

.search-wrapper {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-wrapper i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 1.05rem;
}

.search-wrapper input {
    width: 100%;
    padding: 15px 15px 15px 55px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    background: #f8fafc;
    color: var(--text);
    transition: all 0.3s ease;
}

.search-wrapper input:focus {
    background: #ffffff;
    border-color: #bfdbfe;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* 2. Boutons Filtres */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--muted);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: #eef2f7;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
    border-color: transparent;
}

/* 3. Grille des Documents */
.grid-docs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    padding-bottom: 50px;
}

/* 4. Cartes (Cards) */
.card-doc {
    background: var(--panel);
    border-radius: 24px;
    padding: 25px;
    box-shadow: var(--shadow);
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card-doc:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
    border-color: #cfe3ff;
}

/* Entête de la carte (Icône + Titre) */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-icon-box {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: 0.3s;
}

/* Couleurs spécifiques selon le type */
.type-ordonnance { background: #ecfdf5; color: #059669; }
.type-certificat { background: #fff7ed; color: #ea580c; }
.type-courrier   { background: #eff6ff; color: #2563eb; }
.type-brouillon  { background: #fef3c7; color: #d97706; }

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 10px;
}

.card-date {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.card-excerpt {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.6;
    background: #f8fafc;
    padding: 12px;
    border-radius: 12px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Badge Brouillon en haut à droite */
.badge-draft {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Zone Vide (Empty State) */
.empty-zone {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 0;
    color: var(--muted);
}

.empty-zone i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #e2e8f0;
}