/* Custom Design inspired by Alashary.org */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
    /* Color Palette - Warm Minimalist */
    --color-primary: #d4a373;
    /* Sand Gold accent */
    --color-primary-dark: #b08d55;
    --color-bg: #f8f9fa;
    /* Light Gray background */
    --color-surface: #ffffff;
    /* White surface */
    --color-text-primary: #1a1a1a;
    /* Almost Black */
    --color-text-secondary: #6c757d;
    /* Muted Gray */
    --color-border: #e2e8f0;
    /* Subtle Border */

    /* Typography */
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', sans-serif;

    /* Spacing & Layout */
    --border-radius-card: 12px;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --color-primary: #d4a373;
    --color-primary-dark: #b08d55;
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-text-primary: #e0e0e0;
    --color-text-secondary: #a0a0a0;
    --color-border: #333333;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Header Redesign */
.header-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: #ffffff;
    /* Fallback */
    background-color: var(--color-surface);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 9999;
    width: 100%;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo img {
    height: 35px;
    width: auto;
    /* Invert colors for light mode (assuming logo is white) */
    filter: invert(1);
    transition: filter 0.3s ease;
}

[data-theme="dark"] .header-logo img {
    /* Reset filter for dark mode (keep logo white) */
    filter: none;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: rotate(15deg);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    padding: 8px 40px 8px 15px;
    border-radius: 20px;
    outline: none;
    width: 200px;
    transition: width 0.3s ease, box-shadow 0.3s ease;
}

.search-input:focus {
    width: 250px;
    box-shadow: 0 0 0 2px var(--color-primary);
}

@media (max-width: 768px) {
    .search-input {
        width: 0;
        padding: 0;
        border: none;
        background: transparent;
    }

    .search-container.active .search-input {
        width: 150px;
        padding: 8px 15px;
        border: 1px solid var(--color-border);
        background: var(--color-bg);
        position: absolute;
        right: 0;
        top: 100%;
        margin-top: 10px;
    }

    .header-logo img {
        height: 32px;
    }
}

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0 0 12px 12px;
    box-shadow: var(--shadow-hover);
    z-index: 999;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.search-suggestions.active {
    display: block;
}

.suggestion-group {
    padding: 10px;
    border-bottom: 1px solid var(--color-border);
}

.suggestion-group:last-child {
    border-bottom: none;
}

.suggestion-title {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    margin-bottom: 5px;
    font-weight: 600;
}

.suggestion-item {
    display: block;
    padding: 8px 10px;
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.suggestion-item:hover {
    background-color: var(--color-bg);
    text-decoration: none;
    color: var(--color-primary);
}

body {
    font-family: var(--font-sans);
    color: var(--color-text-primary);
    background-color: var(--color-bg);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-serif);
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

/* Navbar Modernization */
.navbar {
    background-color: var(--color-surface) !important;
    box-shadow: var(--shadow-soft);
    border-bottom: 1px solid var(--color-border);
}

.navbar-brand,
.nav-link {
    color: var(--color-text-primary) !important;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--color-primary) !important;
    filter: brightness(1.2);
}

/* Hero Section */
.hero-section {
    background: var(--color-surface);
    padding: 4rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 2rem;
}

.hero-title {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-family: var(--font-sans);
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem auto;
}

/* Card Component */
.card-modern {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-card);
    padding: 1.5rem;
    /* Reduced padding for grid items */
    margin-bottom: 2rem;
    /* Margin handled by grid gap */
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.card-modern:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--color-primary);
}

.card-modern img {
    border-radius: var(--border-radius-card);
    margin-bottom: 1rem;
    object-fit: cover;
    width: 100%;
    height: 150px;
}

/* Detail View Image Override */
.sidenav {
    background-color: var(--color-surface);
}

.card-detail-img {
    height: auto !important;
    min-height: 0 !important;
}

.card-detail-img img {
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
}

.card-modern h2,
.card-modern h3,
.card-modern h4 {
    margin-top: 0;
    font-size: 1.2rem;
}

.card-modern a {
    text-decoration: none;
    color: inherit;
}

/* Grid Layouts */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

/* Author Bubbles */
.author-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    padding: 2rem 0;
}

.author-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--color-text-primary);
    transition: transform 0.2s ease;
}

.author-bubble:hover {
    transform: scale(1.05);
    color: var(--color-primary);
    text-decoration: none;
}

.author-bubble img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-soft);
    margin-bottom: 0.5rem;
    border: 2px solid var(--color-surface);
    transition: border-color 0.2s ease;
}

.author-bubble:hover img {
    border-color: var(--color-primary);
}

.author-bubble span {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.9rem;
}


/* Typography Helpers */
.text-serif {
    font-family: var(--font-serif);
}

.text-muted {
    color: var(--color-text-secondary) !important;
}

.text-accent {
    color: var(--color-primary);
}

/* Button Overrides */
.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* Breadcrumb Redesign - Global */
.breadcrumb {
    background-color: transparent !important;
    padding: 0;
    margin-bottom: 1rem;
    padding-top: 10px;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    border-radius: 0;
}

.breadcrumb-item {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
}

.breadcrumb-item+.breadcrumb-item::before {
    display: inline-block;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
    color: var(--color-text-secondary);
    content: "/";
}

.breadcrumb-item a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 500;
}

.breadcrumb-item a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--color-text-primary);
    font-weight: 600;
}

/* Quote Specific Styles */
.quote-text {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--color-text-primary);
    line-height: 1.8;
}

/* Related Phrases Section Header - Global */
.related-phrases-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--color-text-primary);
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-primary);
    display: inline-block;
    padding-bottom: 0.5rem;
}

.quote-author {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-top: 1rem;
    display: block;
}

/* Footer clean up */
footer {
    background-color: #1a1a1a !important;
    /* Dark footer for contrast */
    color: #e2e8f0;
}

/* AI Insight Box */
.ai-insight-box {
    background-color: #fff8e1;
    /* Light yellow/gold tint */
    border-left: 4px solid var(--color-primary);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
}

.ai-insight-box strong {
    color: var(--color-primary-dark);
}

/* Dark Mode Override for AI Box */
[data-theme="dark"] .ai-insight-box {
    background-color: rgba(212, 163, 115, 0.15);
    color: var(--color-text-primary);
    border-left-color: var(--color-primary);
}

[data-theme="dark"] .ai-insight-box strong {
    color: var(--color-primary);
}

/* AI Enrichment Box (General) */
.ai-enrichment-box {
    background-color: #f9f9f9;
    border-radius: 8px;
    text-align: left;
    margin: 20px;
    padding: 20px;
    color: #1a1a1a;
}

[data-theme="dark"] .ai-enrichment-box {
    background-color: #1e1e1e;
    /* Match surface color or slightly lighter */
    color: #e0e0e0;
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .ai-enrichment-box h3 {
    color: var(--color-primary);
}

/* Logo Fix for White Background */
.navbar-logo {
    filter: invert(1) grayscale(100%) brightness(0);
    /* Forces black */
    opacity: 0.9;
}

/* Sidebar Redesign */
.sidenav {
    height: calc(100% - 50px);
    /* Height minus header */
    width: 0;
    position: fixed;
    z-index: 999;
    /* Below header if header is z-1000, or just manage stacking context */
    top: 50px;
    /* Opens below the 50px header */
    left: 0;
    background-color: var(--color-surface);
    overflow-x: hidden;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    padding-top: 0;
}

.sidenav a {
    padding: 1rem 1.5rem;
    text-decoration: none;
    font-size: 1rem;
    color: var(--color-text-primary);
    display: block;
    transition: 0.2s ease;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-sans);
    font-weight: 500;
}

.sidenav a:hover {
    color: var(--color-primary);
    background-color: var(--color-bg);
    padding-left: 2rem;
    /* Slide effect */
}

.sidenav .closebtn {
    position: absolute;
    top: 0;
    right: 10px;
    font-size: 2rem;
    margin-left: 0;
    border-bottom: none;
    padding: 0.5rem 1rem;
}

/* Horizontal Card Design (Requested by User) */
.card-horizontal {
    display: flex;
    flex-direction: row;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-card);
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 280px;
    /* Ensure visual balance */
}

.card-horizontal:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--color-primary);
}

.card-horizontal-img {
    width: 35%;
    min-width: 250px;
    position: relative;
    overflow: hidden;
    background-color: #eee;
}

.card-horizontal-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.5s ease;
}

.card-horizontal:hover .card-horizontal-img img {
    transform: scale(1.03);
}

.card-horizontal-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center content vertically */
    width: 65%;
    flex-grow: 1;
    position: relative;
}

.card-horizontal-quote {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-style: italic;
    color: var(--color-text-primary);
    margin-bottom: 2rem;
    line-height: 1.4;
}

/* Specific styling for highlighted words if we implement that logic later */
.highlight-text {
    color: var(--color-primary-dark);
    font-weight: 500;
}

.card-horizontal-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    margin-top: auto;
    width: 100%;
}

.card-horizontal-author {
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-horizontal-author i {
    color: #ccc;
    font-size: 1.2rem;
}

.card-action-link {
    color: var(--color-primary);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.2s;
}

.card-action-link:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .card-horizontal {
        flex-direction: column;
    }

    .card-horizontal-img {
        width: 100%;
        height: 250px;
        min-height: 250px;
    }

    .card-horizontal-body {
        width: 100%;
        padding: 1.5rem;





        .card-horizontal-quote {
            font-size: 1.35rem;
        }
    }
}

/* Related Themes Grid */
.related-themes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 per line on mobile */
    gap: 1rem;
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.related-theme-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--color-text-primary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-card);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.related-theme-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.related-theme-img-container {
    width: 100%;
    height: 150px;
    /* Specific height for images */
    overflow: hidden;
    background-color: var(--color-bg);
    position: relative;
}

.related-theme-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.related-theme-card:hover .related-theme-img {
    transform: scale(1.05);
}

.related-theme-title {
    padding: 0.75rem 0.5rem;
    font-size: 0.95rem;
    text-align: center;
    font-weight: 600;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .related-themes-grid {
        grid-template-columns: repeat(3, 1fr);
        /* 3 per line on desktop */
    }
}