@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --brand-blue: #4a90e2;
}

html {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    padding-top: 52px !important;
    box-sizing: border-box;
    min-height: 100%;
    overflow-x: hidden;
    width: 100%;
}

body.slim-header-active {
    padding-top: 42px;
}

/* Desktop: No slim-header animation */
@media (min-width: 992px) {
    body.slim-header-active {
        padding-top: 72px;
        /* Keep fixed on desktop */
    }

    .navbar.slim-header {
        padding: 0.8rem 0 !important;
        /* No change on desktop */
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    color: #1a1a1a;
}

/* Navbar */
.navbar {
    background-color: #4a90e2 !important;
    border-bottom: none;
    padding: 0.4rem 0;
    /* Tightened from 1rem */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: padding 0.3s ease, min-height 0.3s ease;
}

/* Main Content Wrapper for Full Height (No-Scroll on short pages) */
main.full-height-main {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.centering-main {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    transition: all 0.2s;
}

.navbar .nav-link:hover {
    color: #ffffff !important;
}

/* Exclude transform from dropdown toggle AND dashboard tabs to prevent "jumping" */
.navbar .nav-link:not(.dropdown-toggle):not(.border-0):hover {
    transform: translateY(-1px);
}

.navbar-toggler {
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 0.25rem 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.15rem rgba(255, 255, 255, 0.2);
}

/* Dropdown on Hover (Desktop only) */
@media (min-width: 992px) {
    .nav-item.dropdown:hover .dropdown-menu {
        display: block;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        right: 0;
        left: auto;
    }

    .dropdown-menu {
        display: block;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
        margin-top: 0;
        right: 0;
        left: auto;
        position: absolute;
        pointer-events: none;
        /* Prevent accidental triggers when hidden */
    }

    .nav-item.dropdown:hover .dropdown-menu {
        pointer-events: auto;
        /* Re-enable when hovering over parent */
    }
}

.dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.dropdown-item {
    font-size: 0.95rem;
    padding: 0.7rem 1.25rem;
    color: #4a5568;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background-color: #f7fafc;
    color: #4a90e2;
}

/* Mobile Adjustments */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: #4a90e2;
        padding: 1rem;
        border-radius: 12px;
        margin-top: 0.5rem;
        /* Tightened from 1rem */
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }

    .nav-link {
        padding: 0.75rem 0;
    }

    .dropdown-menu {
        background-color: transparent;
        border: none;
        display: none;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        position: static;
        width: 100%;
        margin-top: 0;
        padding-left: 1rem;
        /* Indent for inline feel */
    }

    .dropdown-menu.show {
        display: block;
    }

    .dropdown-item {
        color: rgba(255, 255, 255, 0.8);
        padding: 0.5rem 0;
    }

    .dropdown-item:hover {
        background-color: transparent;
        color: #ffffff;
    }

    .dropdown-divider {
        border-top-color: rgba(255, 255, 255, 0.1);
        margin: 0.25rem 0;
    }

    /* Hide arrow on mobile toggle */
    .dropdown-toggle::after {
        display: none;
    }
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
    border-left: 4px solid #4a90e2 !important;
    position: relative;
    overflow: hidden;
}

.hero-section::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: rgba(74, 144, 226, 0.05);
    border-radius: 50%;
    z-index: 0;
}

/* Home Page Specifics */
.post-card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.post-card-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

.text-brand {
    color: #4a90e2 !important;
}


.text-muted {
    font-size: 0.9rem;
    color: #6c757d !important;
}

/* Buttons */
.btn-primary {
    background-color: #4a90e2;
    border-color: #4a90e2;
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: #357abd;
    border-color: #357abd;
    transform: translateY(-1px);
}

/* Unified Desktop Action Buttons */
.btn-uniform {
    min-width: 75px;
    padding: 0.35rem 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

/* Slim Header on Scroll Overlay */
.navbar.slim-header {
    padding: 0.4rem 0 !important;
}

/* Logged-in Indicator */
.nav-item-user {
    position: relative;
}

.user-indicator-dot {
    width: 10px;
    height: 10px;
    background-color: #10b981;
    border-radius: 50%;
    position: absolute;
    top: 5px;
    right: 5px;
    border: 2px solid #4a90e2;
}

/* Mobile Button Sizing Utility */
@media (max-width: 575.98px) {
    .btn-mobile-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    .btn-mobile-label {
        font-size: 0.85rem;
        font-weight: 600;
        padding: 0.6rem 0.25rem;
    }
}

.dashboard-mobile-card {
    border-radius: 12px;
    background: #ffffff;
    transition: box-shadow 0.2s;
}

.post-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .post-meta {
        gap: 1rem;
    }
}

.post-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1;
}

.post-meta-item svg,
.post-meta-item .emoji-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Post Actions */
.post-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    /* Ensure buttons wrap on very small screens */
}

/* Dashboard Table Refinements */
.table-responsive {
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
}

.table {
    margin-bottom: 0;
    background-color: transparent !important;
}

.table thead th {
    background-color: #f8fafc;
    border-top: none;
    border-bottom: 2px solid #e2e8f0;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 1rem 1.5rem;
}

.table tbody td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

/* Mobile Card-style Tables */
@media (max-width: 767.98px) {
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tr {
        display: block;
        margin-bottom: 0.75rem;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        padding: 0.5rem;
    }

    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 0.5rem 0.75rem !important;
        border-bottom: 1px solid #f1f5f9;
    }

    .table-mobile-cards td:last-child {
        border-bottom: 0;
    }

    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: #64748b;
        margin-right: 1rem;
        text-align: left;
    }

    .table-mobile-cards td .fw-bold {
        font-size: 0.95rem;
    }
}

@media (max-width: 991.98px) {
    .nav-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        white-space: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        border-bottom: none !important;
        gap: 8px;
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        cursor: grab;
        user-select: none;
    }

    .nav-tabs.grabbing {
        cursor: grabbing;
        scroll-snap-type: none;
        /* Disable snapping while dragging for smoother feel */
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari/Opera */
    }

    .nav-tabs .nav-item {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .nav-tabs .nav-link {
        padding: 0.5rem 1rem !important;
        font-size: 0.9rem;
    }
}

/* Dashboard Pills Tabs - Hover State */
@media (hover: hover) {
    .nav-tabs .nav-link:hover:not(.active) {
        background-color: rgba(74, 144, 226, 0.1) !important;
        color: var(--brand-blue) !important;
        transform: none !important;
        /* Stop jumping */
    }
}

.table-responsive tbody td {
    vertical-align: middle;
}

/* Post Content */
.post-banner {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #2d3748;
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.post-content p {
    margin-bottom: 1.25rem;
}

.post-content code {
    background-color: #2d3748;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e2e8f0;
}

.post-content pre {
    background-color: #1a202c;
    padding: 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border: 1px solid #2d3748;
    overflow-x: auto;
}

.post-content pre code {
    background-color: transparent !important;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.95rem;
}

.post-content img {
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    margin: 2rem 0;
    max-width: 100%;
    max-height: 300px;
    height: auto;
    object-fit: contain;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

/* Badge */
.badge {
    border-radius: 4px;
    /* More modern than pill sometimes, or stick to pill */
    font-weight: 500;
    padding: 0.4em 0.6em;
}

/* Footer */
footer {
    background-color: #fff;
    border-top: 1px solid #eaeaea;
}

/* CKEditor Sticky Toolbar Fix */
.ck.ck-editor__top {
    position: sticky !important;
    top: 82px !important;
    /* Increased for breathing room */
    z-index: 1020 !important;
    border-top: none !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

.ck-editor {
    overflow: visible !important;
}

body.slim-header-active .ck.ck-editor__top {
    top: 52px !important;
    /* Increased for breathing room */
}

.ck-editor__editable {
    min-height: 400px;
    border-radius: 0 0 8px 8px !important;
}

/* Slim Layout for Zero-Scroll Search Pages */
body.hide-footer footer {
    display: none !important;
}

.slim-layout .row .mb-4 {
    margin-bottom: 0.5rem !important;
}

/* Title row */
.slim-layout form.mb-5 {
    margin-bottom: 1rem !important;
}

/* Search form */
.slim-layout #results-section h3 {
    margin-bottom: 0.25rem !important;
    margin-top: 0 !important;
    font-size: 1.25rem;
}

.slim-layout #results-section hr {
    margin: 0.5rem 0 !important;
}

@media (hover: hover) {
    .btn-outline-danger:hover {
        background-color: #dc3545 !important;
        color: #fff !important;
    }
}

/* Specific override for Favorites filter button: No hover/focus effects ever */
#fast-fav-btn.btn-outline-danger:hover,
#fast-fav-btn.btn-outline-danger:active,
#fast-fav-btn.btn-outline-danger:focus,
#fast-fav-btn.btn-outline-danger.active,
#fast-fav-btn.btn-outline-danger:focus-visible {
    background-color: transparent !important;
    color: #dc3545 !important;
    border-color: #dc3545 !important;
    box-shadow: none !important;
}

#fast-fav-btn.btn-danger:hover,
#fast-fav-btn.btn-danger:active,
#fast-fav-btn.btn-danger:focus,
#fast-fav-btn.btn-danger.active,
#fast-fav-btn.btn-danger:focus-visible {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
    box-shadow: none !important;
}

.slim-layout .card {
    margin-bottom: 0.5rem !important;
}

/* Auto-scroll Offset for Fixed Header */
#results-section,
#results-section-mobile {
    scroll-margin-top: 80px;
}

/* Dashboard Fluid Layout */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    width: 100%;
}

@media (max-width: 1200px) {
    .dashboard-container {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding-left: 0;
        padding-right: 0;
    }
}

.container-fluid {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 991px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Dashboard Table Refinements */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
}

.table th {
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #64748b;
    vertical-align: middle;
}

.table td {
    vertical-align: middle;
    white-space: nowrap;
}

/* Allow title to wrap if needed but keep other columns tight */
.table td:first-child {
    white-space: normal;
    min-width: 150px;
}

.table {
    width: 100% !important;
}

.btn-uniform {
    min-width: 70px;
}

.btn-compact {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    line-height: 1.2;
    border-radius: 4px;
    font-weight: 600;
}

.action-group {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    align-items: center;
}

.btn-mobile-compact {
    font-size: 0.85rem !important;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Cleaned up empty ruleset */

@media (max-width: 991.98px) {
    .table-responsive {
        border-right: 1px solid #dee2e6;
    }
}

/* Responsive Width Utilities */
@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }
}

@media (min-width: 992px) {
    .w-lg-auto {
        width: auto !important;
    }
}

/* Profile Enhancements */
.profile-avatar {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.profile-avatar-sm {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.social-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Post Images Gallery */
.post-image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.post-gallery-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.post-gallery-img:hover {
    transform: scale(1.02);
}

/* Avatar Remove Button */
.avatar-remove-btn {
    width: 26px;
    height: 26px;
    transform: translate(30%, -30%);
    z-index: 10;
}

/* Avatar Upload Button */
.avatar-upload-btn {
    width: 32px;
    height: 32px;
    z-index: 5;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    background-color: #4a90e2;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    background-color: #357abd;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}