/* =========================================
   DENSITY SYSTEM (Normal / Compact)
   ========================================= */
:root {
    /* Density Variables — Normal mode defaults */
    --base-font-size: 14px;
    --spacing-scale: 1;
    --card-padding: 1rem;
    --button-padding-y: 0.45rem;
    --button-padding-x: 0.9rem;

    /* Theme Colors */
    --color-primary: #00695c;
    --color-primary-dark: #004d40;
    --color-secondary: #0277bd;
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-text: #212529;
    --color-muted: #6c757d;
    --color-border: #e9ecef;
    --radius: 14px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Compact density overrides */
html[data-density="compact"] {
    --base-font-size: 13px;
    --spacing-scale: 0.85;
    --card-padding: 0.75rem;
    --button-padding-y: 0.35rem;
    --button-padding-x: 0.7rem;
}

/* Apply base font size from density */
html {
    font-size: var(--base-font-size);
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    padding-top: var(--header-height, 70px);
    /* Space for fixed header — adjusted dynamically by JS */
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Header */
.glass-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 0;
}

.brand-text {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.user-email {
    font-size: 0.9rem;
    color: var(--color-muted);
    font-weight: 500;
}

/* =========================================
   HEADER ACTIONS (Navbar Buttons)
   ========================================= */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.header-btn {
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    line-height: 1.4;
    cursor: pointer;
}

/* Calculate Button — Green Gradient */
.btn-calculate-header {
    background: linear-gradient(135deg, #2e7d32, #43a047);
    color: #ffffff !important;
    border: none;
}

.btn-calculate-header:hover,
.btn-calculate-header:focus {
    background: linear-gradient(135deg, #1b5e20, #388e3c);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(46, 125, 50, 0.35);
}

/* Logout Button — Soft Red Outline */
.btn-logout-header {
    background: #ffffff;
    color: #d32f2f !important;
    border: 2px solid #ef5350;
}

.btn-logout-header:hover,
.btn-logout-header:focus {
    background: #ef5350;
    color: #ffffff !important;
    border-color: #ef5350;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(239, 83, 80, 0.3);
}

/* Tablet: wrap nicely */
@media (max-width: 768px) {
    .header-actions {
        width: 100%;
        justify-content: center;
        margin-top: 6px;
    }
}

/* Mobile: stack vertically, full width */
@media (max-width: 480px) {
    .header-actions {
        flex-direction: column;
        gap: 8px;
    }

    .header-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* Typography Overrides */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-main);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.text-primary-dark {
    color: var(--color-primary-dark);
}

.text-muted {
    color: var(--color-muted) !important;
}

.text-justificado {
    text-align: justify;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--radius);
    background-color: var(--color-surface) !important;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.card:hover {
    /* Sutil efecto hover para interactividad */
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
    /* Sombra ligeramente más fuerte al hover */
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--color-border);
    padding: 1.25rem;
}

.card-header h5,
.card-header h6 {
    color: var(--color-primary-dark);
    font-weight: 700;
    margin: 0;
}

/* Inputs & Forms */
.form-control {
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background-color: #fff;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(2, 119, 189, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: var(--button-padding-y) var(--button-padding-x);
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.btn-success {
    background-color: var(--color-secondary);
    border-color: var(--color-secondary);
}

.btn-success:hover {
    background-color: #01579b;
    /* Darker Blue */
    border-color: #01579b;
}

.btn-outline-light {
    /* Reemplazo para botones "transparentes" que ahora son outline primary */
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline-light:hover {
    background-color: var(--color-primary);
    color: white;
}

/* Map specific override for the button inside map container area if needed */
#select-location {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: white;
}

#select-location:hover {
    background: var(--color-primary);
    color: white;
}

/* Map Container */
#map {
    height: 350px;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: inner 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Sombra interna sutil */
}

/* Locations Info */
#location-info {
    color: var(--color-muted) !important;
    font-weight: 500;
}

/* Bicho List Items */
.bicho-item {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all 0.2s ease;
}

.bicho-item:hover {
    border-color: var(--color-secondary);
    background-color: #e1f5fe;
    /* Light Blue tint */
}

.bicho-img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    /* Circular images */
    object-fit: cover;
    margin-right: 1rem;
    border: 2px solid var(--color-border);
    background: #fff;
    cursor: zoom-in;
}

.form-check-label span.fw-semibold {
    color: var(--color-text);
    font-size: 1rem;
}

.bicho-descripcion {
    color: var(--color-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Results Panel */
.result-panel {
    background-color: #f1f3f5;
    border-radius: var(--radius);
    padding: 2rem;
    margin-top: 1.5rem;
}

.display-4 {
    font-weight: 800;
    color: var(--color-text);
}

/* Quality Badges / Classes */
.quality-excelente {
    background: #e0f7fa;
    color: #006064;
    border-left: 5px solid #00acc1;
}

.quality-muy-buena {
    background: #e3f2fd;
    color: #0d47a1;
    border-left: 5px solid #42a5f5;
}

.quality-buena {
    background: #e8f5e9;
    color: #1b5e20;
    border-left: 5px solid #66bb6a;
}

.quality-regular {
    background: #fff3e0;
    color: #e65100;
    border-left: 5px solid #ffa726;
}

.quality-mala {
    background: #ffebee;
    color: #b71c1c;
    border-left: 5px solid #ef5350;
}

.quality-peligrosa {
    background: #37474f;
    color: #fff;
    border-left: 5px solid #263238;
}

/* History List */
.list-group-item {
    background-color: var(--color-surface) !important;
    color: var(--color-text) !important;
    border: 1px solid var(--color-border);
    margin-bottom: 0.5rem;
    border-radius: 8px !important;
}

.list-group-item button.delete-consulta {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.list-group-item button.delete-consulta:hover {
    opacity: 1;
}

.location-badge {
    background-color: #e7f1ff;
    color: #0d6efd;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: inline-block;
    margin-left: 4px;
    white-space: nowrap;
}

/* Tutorial Text */
.tutorial-text {
    background: #fff;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-secondary);
}

.tutorial-text p {
    color: #495057;
    margin-bottom: 1rem;
}

.tutorial-text strong {
    color: var(--color-primary);
}

/* Utils */
.main-container {
    max-width: 1000px;
    margin: 0 auto;
    flex: 1;
    width: 100%;
}

.content-wrapper {
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
}

/* =========================================
   DENSITY-DRIVEN SPACING
   ========================================= */
p {
    line-height: calc(1.5 * var(--spacing-scale));
}

.card-body {
    padding: var(--card-padding);
}

.list-group-item {
    padding: calc(0.6rem * var(--spacing-scale));
}

/* Density Toggle Button */
.density-toggle {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

/* Spinner */
.spinner-border {
    border-color: var(--color-primary);
    border-right-color: transparent;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding-top: calc(var(--header-height, 70px) + 10px);
    }

    .display-5 {
        font-size: 1.75rem;
    }

    .card-tools {
        flex-direction: column;
    }

    .bicho-item {
        padding: 0.75rem;
    }

    #map {
        height: 250px;
    }
}

/* =========================================
   MAIN ACTION BUTTONS (Calculate / Reset / New)
   ========================================= */
.action-buttons,
.action-buttons-bottom {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 15px 0;
}

.main-action-btn {
    padding: 12px 22px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    min-width: 180px;
    cursor: pointer;
    letter-spacing: 0.2px;
}

/* Calculate — Green Gradient (Primary) */
.main-action-btn.calculate {
    background: linear-gradient(135deg, #2e7d32, #43a047);
    color: #ffffff !important;
    border: none;
}

.main-action-btn.calculate:hover,
.main-action-btn.calculate:focus {
    background: linear-gradient(135deg, #1b5e20, #388e3c);
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(46, 125, 50, 0.35);
}

/* Reset — Neutral Light */
.main-action-btn.reset {
    background: #f5f5f5;
    color: #555555 !important;
    border: 1px solid #cccccc;
}

.main-action-btn.reset:hover,
.main-action-btn.reset:focus {
    background: #e0e0e0;
    color: #333333 !important;
    border-color: #bbbbbb;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* New Query — Slate Gradient (Secondary) */
.main-action-btn.new {
    background: linear-gradient(135deg, #546e7a, #78909c);
    color: #ffffff !important;
    border: none;
}

.main-action-btn.new:hover,
.main-action-btn.new:focus {
    background: linear-gradient(135deg, #37474f, #546e7a);
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(84, 110, 122, 0.35);
}

/* Mobile: stack vertically, full width */
@media (max-width: 480px) {

    .action-buttons,
    .action-buttons-bottom {
        flex-direction: column;
        gap: 8px;
    }

    .main-action-btn {
        width: 100%;
        min-width: unset;
        padding: 13px 16px;
        font-size: 1rem;
    }
}

/* Footer Global */
.app-footer {
    background-color: var(--color-bg);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    text-align: center;
    width: 100%;
}

.app-footer img {
    height: 40px;
    width: auto;
    object-fit: contain;
    /* Ensure it looks professional */
}

/* Dashboard Público */
.dashboard-placeholder {
    transition: opacity 0.3s ease;
}

.dashboard-card {
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    background: linear-gradient(to bottom right, #ffffff, #f8f9fa);
}

.dashboard-title {
    color: var(--color-primary-dark);
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-secondary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    font-weight: 500;
}

.top-bichos-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.top-bicho-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.top-bicho-item:last-child {
    border-bottom: none;
}

.top-bicho-name {
    font-weight: 500;
    color: var(--color-text);
}

.top-bicho-count {
    color: var(--color-secondary);
    font-weight: 600;
    background: #e1f5fe;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.quality-bars {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
    background: #e9ecef;
}

.quality-bar {
    height: 100%;
}

/* =========================================
   MOBILE & RESPONSIVE DESIGN
   ========================================= */

/* Mobile (< 768px) */
@media (max-width: 767.98px) {

    /* Header / Navbar */
    .glass-header .container-fluid {
        flex-direction: column;
        gap: 0.75rem;
    }

    .navbar-brand {
        width: 100%;
        justify-content: center;
        margin-right: 0;
        text-align: center;
    }

    .brand-text {
        font-size: 1.1rem;
        /* Slightly smaller on mobile */
    }

    .glass-header .d-flex.align-items-center.gap-3 {
        width: 100%;
        justify-content: center;
        width: 100%;
    }

    /* Typography */
    .display-5 {
        font-size: 1.5rem;
        /* Smaller main title */
        word-wrap: break-word;
    }

    .lead {
        font-size: 1rem;
    }

    /* Layout & Spacing */
    .main-container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-body {
        padding: 1rem;
        /* Reduce padding on mobile */
    }

    /* Buttons */
    .action-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem !important;
        /* Increase gap for touch targets */
    }

    .action-buttons .btn {
        width: 100%;
        display: block;
        padding: 0.75rem;
        /* Larger touch area */
    }

    /* Map Section */
    .map-controls {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    #select-location {
        width: 100%;
        padding: 0.75rem;
    }

    #location-info {
        text-align: center !important;
        width: 100%;
        margin-top: 0.25rem;
    }

    #map {
        height: 280px;
        /* Slightly taller than previous mobile style for better usability */
    }

    /* Forms */
    .input-group {
        flex-direction: column;
    }

    .input-group>.form-control {
        width: 100% !important;
        border-radius: var(--radius) !important;
        margin-bottom: 0.5rem;
    }

    .input-group>.btn {
        width: 100%;
        border-radius: var(--radius) !important;
    }

    #favorites-list .list-group-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    #favorites-list .btn-sm {
        width: 100%;
        margin-top: 0.25rem;
    }

    /* Macroinvertebrates Grid */
    .bicho-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .bicho-img {
        margin-right: 0;
        margin-bottom: 0.5rem;
        width: 64px;
        height: 64px;
    }

    .form-check {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding-left: 0;
        /* Reset bootstrap padding */
    }

    .form-check-input {
        margin-left: 0;
        margin-bottom: 0.5rem;
        float: none;
    }

    /* Dashboard */
    .dashboard-placeholder .row,
    .dashboard-app .row {
        flex-direction: column;
    }

    .dashboard-placeholder .col-md-3,
    .dashboard-placeholder .col-md-4,
    .dashboard-placeholder .col-md-6,
    .dashboard-app .col-md-3,
    .dashboard-app .col-md-4,
    .dashboard-app .col-md-6 {
        width: 100%;
        margin-bottom: 1rem;
    }

    .stat-item {
        margin-bottom: 0.5rem;
    }

    /* History */
    #history-list .list-group-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    #history-list small.text-muted {
        display: block;
        margin-bottom: 0.25rem;
    }

    #history-list .badge {
        display: inline-block;
        margin-bottom: 0.5rem;
    }

    /* Login / Auth */
    #auth-container .col-12 {
        padding: 0;
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .container-fluid {
        max-width: 95%;
    }

    .bicho-item {
        padding: 0.5rem;
    }

    .bicho-descripcion {
        font-size: 0.8rem;
    }
}

/* =========================================
   ANIMATIONS
   ========================================= */
.animate__animated {
    animation-duration: 0.5s;
    animation-fill-mode: both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate__fadeIn {
    animation-name: fadeIn;
}

.d-none {
    display: none !important;
}

/* =========================================
   COLLAPSIBLE & TOGGLE STYLES
   ========================================= */
.toggle-btn {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    color: var(--primary-dark);
    text-decoration: underline !important;
}

/* Mobile specific for toggles */
@media (max-width: 767.98px) {
    .toggle-btn {
        width: 100%;
        padding: 10px;
        background-color: #f8f9fa;
        border-radius: 8px;
        border: 1px solid #dee2e6;
        text-decoration: none !important;
        margin-top: 10px;
    }

    .toggle-btn:hover {
        background-color: #e9ecef;
    }
}

/* =========================================
   MOBILE TOOLTIP COMPONENT
   ========================================= */
.mobile-tooltip {
    position: absolute;
    max-width: 260px;
    background: rgba(40, 40, 40, 0.95);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}


/* =========================================
   MACROINVERTEBRATES GRID LAYOUT
   ========================================= */
.macro-grid {
    display: grid !important;
    gap: 16px;
}

/* Ensure child elements (Bootstrap cols) take full width of the grid cell */
.macro-grid>[class*="col-"] {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Avoid Bootstrap flex behavior */
.macro-grid::before,
.macro-grid::after {
    display: none !important;
}

.bicho-item {
    width: 100% !important;
    max-width: none !important;
}

@media (min-width: 768px) {
    .macro-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1400px) {
    .macro-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* =========================================
   FAVORITES & HISTORY GRIDS
   ========================================= */

.favorites-grid,
.history-grid {
    display: grid !important;
    gap: 20px;
    /* Balanced columns - professional grid */
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    align-items: start;
    /* Prevents cards from stretching vertically */
    width: 100%;
}

/* Ensure no column stacking imbalance */
.favorites-grid::before,
.favorites-grid::after,
.history-grid::before,
.history-grid::after {
    display: none !important;
}

/* Common Card Styles for Lists */
.favorite-item,
.history-item {
    background: #ffffff !important;
    border-radius: 14px !important;
    padding: 16px !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
    height: auto !important;
    /* CRITICAL: No fixed height or stretching */
    margin: 0 !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.favorite-item:hover,
.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08) !important;
}

/* Favorites Card Content */
.favorite-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.favorite-item span {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text);
}

.favorite-item div {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.favorite-item .btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    height: auto;
    flex-shrink: 0;
}

/* History Card Content */
.history-item {
    gap: 12px;
}

.history-item>div:first-child {
    flex: 1;
    min-width: 0;
    line-height: 1.5;
}

.history-item strong {
    color: var(--color-primary-dark);
    font-size: 0.95rem;
}

.history-item .location-badge {
    margin: 4px 0;
}

.history-item .delete-consulta {
    align-self: flex-start;
    margin-top: 8px;
}

/* Maintain grid flow even when items are hidden */
.favorites-grid>.d-none,
.history-grid>.d-none {
    display: none !important;
}

/* Tablet / Large Mobile Adjustments */
@media (max-width: 768px) {

    .favorites-grid,
    .history-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* =========================================
   TAB NAVIGATION (Navbar Integrated)
   ========================================= */

/* Hide tabs when not logged in */
#app-nav-tabs {
    display: none;
}

#app-nav-tabs.visible-tabs {
    display: flex;
}

.nav-link.tab-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--color-muted);
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.nav-link.tab-btn:hover {
    background: #e8f5e9;
    color: var(--color-primary);
}

.nav-link.tab-btn.active {
    background: #2f6f4f;
    color: #ffffff !important;
    border-radius: 8px;
}

/* =========================================
   USER PANEL (Navbar)
   ========================================= */
.user-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.user-panel .user-email {
    font-size: 0.85rem;
    color: #2f3e46;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-panel .user-email i {
    font-size: 1.1rem;
    color: var(--color-primary);
    flex-shrink: 0;
}

.user-panel .logout-btn {
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 5px 12px;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .user-panel {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
        padding: 8px 12px;
    }

    .user-panel .user-email {
        max-width: 180px;
        font-size: 0.8rem;
    }
}

/* =========================================
   TAB SECTION VISIBILITY + TRANSITIONS
   ========================================= */
.tab-section {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.tab-section.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* =========================================
   NAVBAR SCROLL EFFECT
   ========================================= */
.glass-header {
    transition: box-shadow 0.3s ease, backdrop-filter 0.3s ease;
}

.glass-header.navbar-scrolled {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(12px);
}

/* Tutorial Video Placeholder */
.tutorial-placeholder {
    background: #f1f3f5;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--color-muted);
}

.tutorial-placeholder h5 {
    color: var(--color-primary-dark);
}

/* =========================================
   VISUAL DENSITY SYSTEM
   ========================================= */
:root {
    --base-font-size: 14px;
    --space-scale: 1;
}

[data-density="compact"] {
    --base-font-size: 13px;
    --space-scale: 0.85;
}

[data-density="normal"] {
    --base-font-size: 15px;
    --space-scale: 1.1;
}

html {
    font-size: var(--base-font-size);
}

.card-body {
    padding: calc(1rem * var(--space-scale));
}

.btn {
    padding:
        calc(0.45rem * var(--space-scale)) calc(0.9rem * var(--space-scale));
}

.form-control {
    padding: calc(0.45rem * var(--space-scale));
}
/* FAVORITES RESPONSIVE FIX */
.favorites-item {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
}

.favorite-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.favorite-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

@media (max-width: 768px) {
    .favorites-item {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .favorite-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 6px;
    }

    .favorite-actions button {
        width: auto;
        min-width: 90px;
    }
}
