:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #f59e0b;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --sidebar-width: 80px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 100dvh;
    height: 100dvh;
}

/* Sidebar */
.sidebar {
    background-color: #1e293b;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    margin-bottom: 30px;
    text-align: center;
}

.logo {
    display: block;
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 8px;
    line-height: 40px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    margin: 0 auto 5px;
}

.logo-text {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.az-nav {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 15px;
}

.az-nav button {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 0;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 6px;
}

.az-nav button:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.az-nav button.active {
    color: white;
    background-color: var(--primary-color);
}

/* Main Content Area */
.main-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

.app-header {
    background-color: var(--bg-card);
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.app-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    color: #0f172a;
    margin-bottom: 2px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.search-container {
    width: 400px;
}

.mode-toggle {
    display: flex;
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
    align-items: center;
}

.nav-divider {
    width: 1px;
    height: 18px;
    background-color: #cbd5e1;
    margin: 0 8px;
}

.nav-ref-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 7px;
    transition: all 0.2s;
}

.nav-ref-link:hover {
    color: var(--text-main);
    background-color: #e2e8f0;
}

.nav-ref-link.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.nav-ref-link svg {
    color: inherit;
}

.toggle-btn {
    border: none;
    background: transparent;
    padding: 6px 16px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    color: var(--text-main);
}

.toggle-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: #f1f5f9;
    border-radius: 30px;
    padding: 4px 6px 4px 16px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.search-bar:focus-within {
    background-color: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.search-icon {
    color: var(--text-muted);
    margin-right: 12px;
}

#searchInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 15px;
}

#searchBtn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#searchBtn:hover {
    background-color: var(--primary-hover);
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px 40px 100px 40px;
    scroll-behavior: smooth;
    min-height: 0;
}

.hidden {
    display: none !important;
}

/* Welcome View */
.welcome-view {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-link-small {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: #f1f5f9;
    color: var(--primary-color);
    border-radius: 6px;
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid transparent;
}

.pdf-link-small:hover {
    background-color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: scale(1.1);
}

.welcome-card {
    text-align: center;
    max-width: 500px;
    padding: 48px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.icon-header {
    font-size: 48px;
    margin-bottom: 24px;
}

.welcome-card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    margin-bottom: 12px;
    color: #0f172a;
}

.welcome-card p {
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.6;
}

.quick-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    border-top: 1px solid #f1f5f9;
    padding-top: 24px;
}

.stat-item {
    font-size: 14px;
    color: var(--text-muted);
}

.stat-item strong {
    display: block;
    font-size: 18px;
    color: var(--primary-color);
}

/* Loading */
#loadingIndicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin: 40px 0;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f1f5f9;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Result Cards */
.result-card {
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
    overflow: hidden;
}

.card-header {
    padding: 24px 32px;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-family: 'Outfit', sans-serif;
    color: #0f172a;
    font-size: 24px;
}

.card-content {
    padding: 32px;
}

.card-section {
    margin-bottom: 24px;
}

.card-section:last-child {
    margin-bottom: 0;
}

.section-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.section-text {
    line-height: 1.7;
    color: #334155;
    font-size: 16px;
}

.relationships-box {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 20px;
    margin-top: 28px;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.08);
    position: relative;
    overflow: hidden;
}

.relationships-box::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background-color: #f59e0b;
}

.relationships-box .section-label {
    color: #92400e;
    font-size: 11px;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

.relationships-box .section-text {
    color: #78350f;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.6;
}

mark.highlighted {
    background-color: #fde047;
    color: #1a1a1a;
    padding: 0 2px;
    border-radius: 2px;
}

/* Therapeutic Specific */
.therapeutic-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.therapeutic-item {
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.therapeutic-item:hover {
    transform: translateX(5px);
    border-color: var(--primary-color);
}

.therapeutic-item h3 {
    font-size: 16px;
    color: var(--primary-color);
    margin-bottom: 6px;
    font-family: 'Outfit', sans-serif;
}

.therapeutic-item p {
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
}

.remedy-link {
    color: var(--primary-color);
    border-bottom: 1px dashed rgba(37, 99, 235, 0.3);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.remedy-link:hover {
    color: #1d4ed8;
    background-color: rgba(37, 99, 235, 0.05);
    border-bottom-color: var(--primary-color);
    border-radius: 2px;
}

.no-results {
    text-align: center;
    padding: 60px;
    color: #64748b;
}

.disabled-nav {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-layout {
        display: flex;
        flex-direction: column;
        height: 100dvh;
    }

    .sidebar {
        flex-direction: row;
        width: 100%;
        padding: 8px;
        order: 2;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    .sidebar-header {
        display: none;
    }

    .az-nav {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
        gap: 4px;
    }

    .az-nav button {
        padding: 10px 16px;
        flex: 0 0 auto;
        font-size: 16px;
    }

    .main-wrapper {
        order: 1;
        flex: 1;
        min-height: 0;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
        gap: 16px;
    }
    
    .header-content {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .app-header h1 {
        font-size: 22px;
        text-align: center;
    }

    .mode-toggle {
        flex-wrap: wrap;
        border-radius: 8px;
    }

    .nav-divider {
        display: none;
    }

    .toggle-btn, .nav-ref-link {
        flex: 1 1 45%;
        text-align: center;
        justify-content: center;
        padding: 8px;
    }

    .search-container {
        width: 100%;
    }

    .content-body {
        padding: 16px 16px 24px 16px;
    }

    .welcome-card {
        padding: 24px 16px;
    }

    .quick-stats {
        flex-direction: column;
        gap: 12px;
    }

    .card-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .card-header h2 {
        font-size: 20px;
    }

    .title-group {
        width: 100%;
        justify-content: space-between;
    }

    .card-content {
        padding: 16px;
    }
    
    .therapeutic-item .item-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }
}