@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
    /* Healthcare Clean Aesthetics (White, Cyan, Sky Blue, Navy) */
    --bg-main: #f0f7fc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-subtle: #f8fafc;
    --bg-input: #f1f5f9;
    
    --primary-blue: #0284c7;        /* Azul Médico Confiável */
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;       /* Azul Céu Suave */
    --primary-accent: #06b6d4;      /* Ciano Saúde */
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
    
    --text-title: #0f172a;          /* Slate Escuro */
    --text-body: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-focus: #38bdf8;
    
    --success-bg: #ecfdf5;
    --success-text: #059669;
    --success-border: #a7f3d0;
    
    --warning-bg: #fffbeb;
    --warning-text: #d97706;
    
    --danger-bg: #fef2f2;
    --danger-text: #dc2626;
    --danger-border: #fecaca;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(2, 132, 199, 0.08), 0 4px 6px -4px rgba(2, 132, 199, 0.05);
    --shadow-float: 0 20px 25px -5px rgba(2, 132, 199, 0.1), 0 8px 10px -6px rgba(2, 132, 199, 0.05);
    
    --sidebar-width: 320px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-body);
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background Soft Atmosphere */
.bg-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.decor-circle-1 {
    position: absolute;
    top: -10vw;
    right: -10vw;
    width: 45vw;
    height: 45vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(186, 230, 253, 0.6) 0%, rgba(240, 247, 252, 0) 70%);
    filter: blur(40px);
}

.decor-circle-2 {
    position: absolute;
    bottom: -15vw;
    left: 20vw;
    width: 40vw;
    height: 40vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(207, 250, 254, 0.5) 0%, rgba(240, 247, 252, 0) 70%);
    filter: blur(50px);
}

/* Sidebar */
aside.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.sidebar-close-btn {
    display: none;
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.sidebar-close-btn:hover {
    background: var(--bg-card-subtle);
    color: var(--text-title);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Navbar */
.mobile-navbar {
    display: none;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    margin: -1rem -1rem 1.25rem -1rem;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-title);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.mobile-menu-btn:hover {
    background: var(--bg-card-subtle);
}

.mobile-brand {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-title);
}

.mobile-brand span {
    color: var(--primary-blue);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-title);
    letter-spacing: -0.02em;
}

.brand-title span {
    color: var(--primary-blue);
}

.patient-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.patient-list-header h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    font-weight: 700;
}

.patient-badge-count {
    background: var(--primary-light);
    color: var(--primary-blue);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
}

ul#patients-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding-right: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

ul#patients-list::-webkit-scrollbar {
    width: 5px;
}
ul#patients-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

ul#patients-list li {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-body);
}

ul#patients-list li:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateX(3px);
}

ul#patients-list li[hidden] { display: none; }

ul#patients-list li.active {
    background: var(--primary-light);
    border-color: #bae6fd;
    color: var(--primary-blue);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.patient-delete-btn {
    opacity: 0.4;
    background: transparent;
    border: none;
    color: var(--danger-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

ul#patients-list li:hover .patient-delete-btn {
    opacity: 0.8;
}

.patient-delete-btn:hover {
    opacity: 1 !important;
    background: var(--danger-bg);
    transform: scale(1.1);
}

/* Main Content Area */
main.content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
}

main.content::-webkit-scrollbar {
    width: 6px;
}
main.content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.consultation-panel {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Cards & Surfaces */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

/* Typography */
h1, h2, h3, h4 {
    color: var(--text-title);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Empty State */
.empty-state-card {
    text-align: center;
    padding: 4rem 2rem;
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.empty-icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-body);
    margin-bottom: 0.4rem;
}

.app-input, select.app-input {
    width: 100%;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-title);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.app-input:focus, select.app-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
    background: #ffffff;
}

textarea.app-input {
    resize: vertical;
    line-height: 1.5;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
    opacity: 0.95;
}

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-color);
    color: var(--text-body);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger-outline {
    background: transparent;
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.btn-danger-outline:hover {
    background: var(--danger-bg);
}

.new-patient-card {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (max-width: 600px) {
    .form-row-2col {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .form-actions-row {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .form-actions-row button {
        width: 100%;
    }
}

/* Header Patient Dashboard */
.patient-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.patient-info-title h2 {
    font-size: 1.75rem;
    font-weight: 800;
}

.badge-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary-blue);
    margin-top: 0.35rem;
}

/* Structured Clinical Data Grid */
.structured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.clinical-box {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.clinical-box-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-title);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-pill {
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-body);
    box-shadow: var(--shadow-sm);
}

.tag-pill.allergy {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #e11d48;
    font-weight: 600;
}

.tag-pill.med {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.tag-pill.fact {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

/* Timeline of Consultations */
.timeline-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2rem 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.consultation-timeline-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    position: relative;
}

.consultation-timeline-item:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
}

.timeline-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.timeline-date {
    font-weight: 700;
    color: var(--text-title);
    font-size: 0.95rem;
}

.status-chip {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.status-chip.COMPLETED { background: var(--success-bg); color: var(--success-text); }
.status-chip.AWAITING_RECORD_REVIEW { background: #eff6ff; color: #1d4ed8; }
.status-chip.AWAITING_TRANSCRIPT_REVIEW { background: var(--warning-bg); color: var(--warning-text); }
.status-chip.RECORD_GENERATION_FAILED, .status-chip.AUDIO_UPLOAD_FAILED { background: var(--danger-bg); color: var(--danger-text); }

/* Pretty SOAP Accordion in Timeline */
.soap-accordion-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}

/* Responsive Design (Mobile & Tablets) */
@media (max-width: 900px) {
    aside.sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        min-width: 300px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport para navegadores mobile */
        padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 20px)) 1.25rem;
        transform: translateX(-100%);
        box-shadow: var(--shadow-float);
    }

    aside.sidebar.open {
        transform: translateX(0);
    }

    #show-new-patient-btn {
        flex-shrink: 0;
        margin-top: 0.75rem;
        padding: 0.85rem;
    }

    .sidebar-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-navbar {
        display: flex;
    }

    main.content {
        padding: 1rem 1rem 2rem 1rem;
        height: 100vh;
        width: 100vw;
    }

    .card {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
        border-radius: var(--radius-md);
    }

    .patient-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .patient-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .patient-header > div:last-child button {
        flex: 1;
        justify-content: center;
    }

    .structured-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .soap-editor-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .soap-accordion-content {
        grid-template-columns: 1fr;
    }

    .recording-container {
        padding: 2rem 0.5rem;
    }

    .timer-clean {
        font-size: 2.25rem;
    }

    .mic-button-clean {
        width: 80px;
        height: 80px;
    }

    .mic-button-clean svg {
        width: 34px;
        height: 34px;
    }
}

.soap-mini-block {
    background: var(--bg-card-subtle);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-blue);
    font-size: 0.85rem;
}

.soap-mini-block.s { border-left-color: #0284c7; }
.soap-mini-block.o { border-left-color: #0d9488; }
.soap-mini-block.a { border-left-color: #eab308; }
.soap-mini-block.p { border-left-color: #10b981; }

.soap-mini-block strong {
    color: var(--text-title);
    display: block;
    margin-bottom: 0.25rem;
}

/* Beautiful SOAP Edit Grid */
.soap-editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin: 1.5rem 0;
}

@media (max-width: 768px) {
    .soap-editor-grid {
        grid-template-columns: 1fr;
    }
}

.soap-card-field {
    background: var(--bg-card-subtle);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.soap-card-field.s { border-top: 4px solid #0284c7; }
.soap-card-field.o { border-top: 4px solid #0d9488; }
.soap-card-field.a { border-top: 4px solid #eab308; }
.soap-card-field.p { border-top: 4px solid #10b981; }

.soap-field-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-title);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Audio Recording UI */
.recording-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1rem;
    gap: 1.5rem;
}

.mic-button-clean {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: none;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(2, 132, 199, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.mic-button-clean svg {
    width: 42px;
    height: 42px;
    fill: currentColor;
}

.mic-button-clean:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 30px rgba(2, 132, 199, 0.45);
}

.mic-button-clean.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
    animation: recording-pulse 1.8s infinite;
}

@keyframes recording-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70% { box-shadow: 0 0 0 24px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.timer-clean {
    font-size: 2.75rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.timer-clean.active {
    color: var(--danger-text);
    font-weight: 600;
}

.status-pill {
    padding: 0.4rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.status-pill.recording { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.status-pill.uploading { background: var(--warning-bg); color: var(--warning-text); }
.status-pill.success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
