/* Modern Theme System */
:root {
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --muted-text: #64748b;
    --nav-bg: #1e293b;
    --nav-text: #f8fafc;
}

body.dark-mode {
    --bg-color: #0f172a;
    --text-color: #f1f5f9;
    --card-bg: #1e293b;
    --card-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --border-color: #334155;
    --accent-color: #60a5fa;
    --accent-hover: #93c5fd;
    --muted-text: #94a3b8;
    --nav-bg: #020617;
}

/* Global Styles */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: 0;
    /* Removing global padding */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
}

/* Add padding only for frontend pages with fixed navbar */
body.frontend-page {
    /* Padding is now handled dynamically by JS to match header height */
    padding-top: 0;
}

/* Unified Navbar Styling */
.navbar.fixed-top,
.navbar.sticky-top {
    min-height: 70px;
    height: auto;
    background-color: #1e293b !important;
    /* Force Dark Blue */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1060;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Force Logo Constraints */
/* Force Logo Constraints */
.navbar-brand img {
    object-fit: contain;
    max-height: 50px;
    /* Constrain height to fit within 70px navbar */
    width: auto;
    /* Maintain aspect ratio */
    max-width: 100%;
    /* Prevent overflow on very narrow screens */
}

/* Ensure Nav Text Visibility */
.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
}

.navbar-dark .navbar-brand {
    color: #fff !important;
}

body.dark-mode .navbar.fixed-top,
body.dark-mode .navbar.sticky-top {
    background-color: #0f172a !important;
    /* Darker for dark mode */
}

.navbar-toggler {
    border: none !important;
    box-shadow: none !important;
}

.navbar .container,
.navbar.sticky-top {
    display: flex;
    align-items: center;
    min-height: 70px;
    /* Internal height for alignment */
}

/* Mobile Navbar Improvements */
@media (max-width: 991.98px) {

    .navbar.fixed-top,
    .navbar.sticky-top {
        height: 70px !important;
    }

    .navbar-collapse {
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        background: rgba(30, 41, 59, 0.98);
        backdrop-filter: blur(20px);
        margin: 0;
        padding: 0;
        border-radius: 0 0 1.5rem 1.5rem;
        box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.5);
        z-index: 1070;
        border: 1px solid rgba(255, 255, 255, 0.05);
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        /* Enable Scrolling */
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .navbar-nav .nav-link {
        text-align: left;
        padding: 1rem 1.5rem !important;
        margin: 0;
        border-radius: 0;
        font-weight: 500;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        /* 1px bottom border */
        transition: all 0.2s ease;
    }

    /* Make dropdowns static on mobile to avoid clipping and allow scrolling */
    .navbar-nav .dropdown-menu {
        position: static !important;
        float: none;
        width: auto;
        margin-top: 0;
        background-color: transparent;
        border: none;
        box-shadow: none;
        padding-left: 1.5rem;
    }

    .navbar-nav .dropdown-menu .dropdown-item {
        color: rgba(255, 255, 255, 0.7);
        padding: 0.5rem 1rem;
    }

    .navbar-nav .dropdown-menu .dropdown-item:hover {
        background: transparent;
        color: var(--accent-color);
    }

    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:active {
        background: rgba(255, 255, 255, 0.05);
        color: var(--accent-color) !important;
    }

    body.dark-mode .navbar-collapse {
        background: rgba(2, 6, 23, 0.98);
        border-color: rgba(255, 255, 255, 0.03);
    }
}

.navbar-brand {
    color: var(--nav-text) !important;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.nav-link {
    color: var(--nav-text) !important;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.nav-link:hover,
.nav-link.active {
    opacity: 1;
}

/* Card Styling */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem;
    font-weight: 600;
}

/* Form Styles */
.form-control,
.form-select {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--card-bg);
    border-color: var(--accent-color);
    color: var(--text-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Helper Classes */
.text-muted {
    color: var(--muted-text) !important;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.625rem 1.25rem;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Admin Specific */
.sidebar {
    position: fixed;
    top: 70px;
    /* Adjusted to sit below the header */
    bottom: 0;
    left: 0;
    z-index: 1030;
    padding: 0;
    /* Adjusted for top gap fix */
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
}

.sidebar-sticky {
    position: relative;
    top: 0;
    height: calc(100vh - 70px);
    padding-top: .5rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar .nav-link {
    color: var(--text-color) !important;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    margin: 4px 12px;
    border-radius: 0.5rem;
    opacity: 1;
}

.sidebar .nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--accent-color) !important;
}

.sidebar .nav-link.active {
    background-color: var(--accent-color) !important;
    color: #fff !important;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

body.dark-mode .sidebar {
    background-color: #020617;
    /* Darker navy for sidebar */
}

/* Mobile Sidebar Fix */
@media (max-width: 767.98px) {
    .sidebar {
        top: 70px;
        height: calc(100vh - 70px);
        padding-top: 1rem !important;
    }

    .sidebar .nav-link {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        /* Divider lines */
        margin: 0 !important;
        border-radius: 0;
        padding: 0.85rem 1.5rem !important;
    }

    body.dark-mode .sidebar .nav-link {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
}

body.dark-mode .sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .nav-link.active {
    background-color: var(--accent-color);
    color: #fff !important;
}

/* Single Post Styling */
.post-featured-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    object-position: center;
    border-radius: 1.25rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.post-body-content {
    font-size: 1.125rem;
    color: var(--text-color);
}

.post-body-content p {
    margin-bottom: 1.5rem;
}

.bg-light.bg-opacity-50 {
    background-color: rgba(248, 250, 252, 0.5) !important;
}

body.dark-mode .bg-light.bg-opacity-50 {
    background-color: rgba(30, 41, 59, 0.5) !important;
}

.rounded-4 {
    border-radius: 1rem !important;
}

.display-4 {
    letter-spacing: -0.05em;
    line-height: 1.2;
}

.entry-title {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--text-color);
}

/* Search Modal Styles */
.search-modal-content {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

body.dark-mode .search-modal-content {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-color);
}

.search-input-group {
    background: var(--bg-color);
    border-radius: 1.5rem;
    padding: 0.5rem;
    transition: box-shadow 0.3s ease;
}

.search-input-group:focus-within {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

#modalSearchInput::placeholder {
    color: var(--muted-text);
    opacity: 0.7;
}

/* Hover Support for Navbar Dropdowns (Desktop) */
@media (min-width: 992px) {
    .navbar .nav-item.dropdown:hover .dropdown-menu {
        display: block;
        animation: fadeIn 0.3s;
        margin-top: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer Utilities */
.hover-white:hover {
    color: #fff !important;
}

.hover-primary:hover {
    color: var(--primary-color) !important;
}

.transition {
    transition: all 0.3s ease;
}