/* ==========================================================================
   GLOBAL LAYOUT STYLES
   Sticky navbar, sticky footer, sidebar scrolling
   ========================================================================== */

/* Base layout - full viewport height with flex */
html, body {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Main content fills available space */
.main-content {
    flex: 1 0 auto;
}

/* ==========================================================================
   FIXED NAVBAR
   ========================================================================== */
/* Use fixed instead of sticky for consistent behavior across all pages */
.navbar.sticky-top,
.navbar.fixed-top {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

/* Add padding to body to account for fixed navbar height */
body {
    padding-top: 56px;
}

/* Remove extra padding for pages that handle it themselves */
body.no-scroll {
    padding-top: 0;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
    flex-shrink: 0;
    margin-top: auto;
    border-top: 1px solid #e9ecef;
}

/* Hide footer on pages that opt out */
body.no-footer .site-footer {
    display: none !important;
}

/* ==========================================================================
   SIDEBAR BASE STYLES
   ========================================================================== */

/* Left sidebar - fixed position with internal scrolling */
.sidebar-fixed-left {
    position: fixed;
    top: 56px; /* Height of navbar */
    left: 0;
    bottom: 0;
    width: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border-right: 1px solid #e9ecef;
    z-index: 1010;
}

/* Right sidebar - fixed position with internal scrolling */
.sidebar-fixed-right {
    position: fixed;
    top: 56px; /* Height of navbar */
    right: 0;
    bottom: 0;
    width: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border-left: 1px solid #e9ecef;
    z-index: 1010;
}

/* Content area adjustments when sidebars are present */
.has-sidebar-left {
    margin-left: 240px;
}

.has-sidebar-right {
    margin-right: 280px;
}

.has-both-sidebars {
    margin-left: 240px;
    margin-right: 280px;
}

/* ==========================================================================
   SCROLLBAR STYLING FOR SIDEBARS
   ========================================================================== */
.sidebar-fixed-left::-webkit-scrollbar,
.sidebar-fixed-right::-webkit-scrollbar {
    width: 6px;
}

.sidebar-fixed-left::-webkit-scrollbar-track,
.sidebar-fixed-right::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-fixed-left::-webkit-scrollbar-thumb,
.sidebar-fixed-right::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar-fixed-left::-webkit-scrollbar-thumb:hover,
.sidebar-fixed-right::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Large screens - full layout */
@media (min-width: 1200px) {
    .sidebar-fixed-left {
        width: 240px;
    }
    .sidebar-fixed-right {
        width: 280px;
    }
    .has-sidebar-left {
        margin-left: 240px;
    }
    .has-sidebar-right {
        margin-right: 280px;
    }
}

/* Medium screens - narrower sidebars */
@media (max-width: 1199px) and (min-width: 992px) {
    .sidebar-fixed-left {
        width: 220px;
    }
    .sidebar-fixed-right {
        width: 260px;
    }
    .has-sidebar-left {
        margin-left: 220px;
    }
    .has-sidebar-right {
        margin-right: 260px;
    }
}

/* Tablet - hide right sidebar, compact left */
@media (max-width: 991px) and (min-width: 768px) {
    .sidebar-fixed-left {
        width: 200px;
    }
    .sidebar-fixed-right {
        display: none;
    }
    .has-sidebar-left {
        margin-left: 200px;
    }
    .has-sidebar-right,
    .has-both-sidebars {
        margin-right: 0;
    }
}

/* Mobile - icon-only left sidebar or hidden */
@media (max-width: 767px) {
    .sidebar-fixed-left {
        width: 60px;
    }
    .sidebar-fixed-left .sidebar-text {
        display: none;
    }
    .sidebar-fixed-right {
        display: none;
    }
    .has-sidebar-left {
        margin-left: 60px;
    }
    .has-sidebar-right,
    .has-both-sidebars {
        margin-right: 0;
    }
}

/* Very small screens - no sidebar */
@media (max-width: 575px) {
    .sidebar-fixed-left {
        display: none;
    }
    .has-sidebar-left,
    .has-both-sidebars {
        margin-left: 0;
    }
}

/* ==========================================================================
   NEW ENTRY BUTTON - Fixed at Bottom Right
   ========================================================================== */
.new-entry-btn-container {
    position: fixed;
    bottom: 80px; /* Above footer */
    right: 20px;
    z-index: 1025;
}

.new-entry-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.new-entry-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.5);
}

/* Adjust for pages with right sidebar */
.has-sidebar-right .new-entry-btn-container {
    right: 300px;
}

@media (max-width: 991px) {
    .has-sidebar-right .new-entry-btn-container {
        right: 20px;
    }

    /* Stack above feedback FAB on mobile */
    .new-entry-btn-container {
        bottom: 144px; /* Above feedback FAB (80px + 64px button height) */
    }
}

/* ==========================================================================
   CSS VARIABLES
   ========================================================================== */
:root {
    --navbar-height: 56px;
    --footer-height: 50px;
    --sidebar-left-width: 240px;
    --sidebar-right-width: 280px;

    /* Mood Colors - Standardized across the site */
    --mood-ecstatic: #22c55e;
    --mood-ecstatic-light: #4ade80;
    --mood-ecstatic-gradient: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);

    --mood-happy: #f59e0b;
    --mood-happy-light: #fbbf24;
    --mood-happy-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);

    --mood-neutral: #6b7280;
    --mood-neutral-light: #9ca3af;
    --mood-neutral-gradient: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%);

    --mood-sad: #3b82f6;
    --mood-sad-light: #60a5fa;
    --mood-sad-gradient: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);

    --mood-angry: #dc2626;
    --mood-angry-light: #ef4444;
    --mood-angry-gradient: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

/* ==========================================================================
   Floating Feedback Button
   ========================================================================== */

.feedback-fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1025;
}

.feedback-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    color: white;
}

.feedback-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
}

/* Adjust position when right sidebar is visible */
@media (min-width: 993px) {
    .has-right-sidebar .feedback-fab-container {
        right: 304px; /* 280px sidebar + 24px margin */
    }
}

/* Move above mobile toggle button on mobile */
@media (max-width: 991px) {
    .feedback-fab-container {
        bottom: 70px; /* Above the sidebar toggle button */
    }

    /* Smaller feedback FAB on mobile */
    .feedback-fab {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
}

/* Very small screens */
@media (max-width: 575px) {
    .feedback-fab-container {
        bottom: 65px;
        right: 16px;
    }

    .feedback-fab {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
}

/* ==========================================================================
   Tutorial Walkthrough
   ========================================================================== */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.tutorial-modal {
    position: fixed;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    animation: tutorialFadeIn 0.3s ease;
}

@keyframes tutorialFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tutorial-modal.tutorial-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
}

.tutorial-content {
    padding: 1.25rem;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tutorial-step-indicator {
    font-size: 0.75rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.tutorial-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.tutorial-close:hover {
    color: #374151;
}

.tutorial-body {
    text-align: center;
    margin-bottom: 1.25rem;
}

.tutorial-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.tutorial-title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.tutorial-text {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 0;
    line-height: 1.5;
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.tutorial-footer .btn {
    min-width: 100px;
}

/* Tutorial arrow */
.tutorial-arrow {
    position: absolute;
    width: 0;
    height: 0;
    display: none;
}

.tutorial-arrow.arrow-left {
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 10px solid white;
}

.tutorial-arrow.arrow-right {
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 10px solid white;
}

.tutorial-arrow.arrow-top {
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid white;
}

/* Spotlight effect for target elements */
.tutorial-highlight {
    position: relative;
    z-index: 10001 !important;
    background: white !important;
    border-radius: 8px;
    /* Glowing border + massive shadow creates the fog effect */
    box-shadow:
        0 0 0 4px rgba(99, 102, 241, 0.6),
        0 0 15px rgba(99, 102, 241, 0.4),
        0 0 0 9999px rgba(0, 0, 0, 0.5) !important;
    animation: tutorialSpotlight 2s infinite;
}

@keyframes tutorialSpotlight {
    0%, 100% {
        box-shadow:
            0 0 0 4px rgba(99, 102, 241, 0.6),
            0 0 15px rgba(99, 102, 241, 0.4),
            0 0 0 9999px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow:
            0 0 0 6px rgba(99, 102, 241, 0.8),
            0 0 25px rgba(99, 102, 241, 0.5),
            0 0 0 9999px rgba(0, 0, 0, 0.5);
    }
}

/* Hide the regular overlay when spotlight is active - the box-shadow creates the fog */
body.tutorial-active.has-spotlight .tutorial-overlay {
    opacity: 0;
    pointer-events: none;
}

/* Allow box-shadow to extend beyond parent containers */
body.tutorial-active.has-spotlight .app-sidebar,
body.tutorial-active.has-spotlight .app-sidebar .sidebar-content,
body.tutorial-active.has-spotlight .feedback-fab-container {
    overflow: visible !important;
}

/* Only the section containing the highlight should have overflow visible */
body.tutorial-active.has-spotlight .sidebar-section-content:has(.tutorial-highlight) {
    overflow: visible !important;
}

/* Prevent body scroll during tutorial */
body.tutorial-active {
    overflow: hidden;
}

/* Mobile adjustments */
@media (max-width: 576px) {
    .tutorial-modal {
        width: calc(100% - 2rem);
        left: 1rem !important;
        right: 1rem !important;
        bottom: 1rem !important;
        top: auto !important;
        transform: none !important;
    }

    .tutorial-modal.tutorial-center {
        top: auto !important;
        left: 1rem !important;
        transform: none !important;
    }

    .tutorial-arrow {
        display: none !important;
    }
}
