/**
 * Future Is Now - Shared Navigation & Responsive CSS
 * Extracted from inline styles duplicated across 22+ pages.
 * Include this in every page: <link rel="stylesheet" href="/css/nav-responsive.css">
 */

/* Header Layout */
.header-left { display: flex; align-items: center; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-img { height: 40px; width: auto; }
.logo-text { font-size: 1.25rem; font-weight: 700; color: #fff; white-space: nowrap; }
.logo:hover .logo-text { color: #3AA6B9; }
.header-center { flex: 1; display: flex; justify-content: center; align-items: center; min-width: 0; }
.header-right { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.connection-status { display: flex; align-items: center; gap: 6px; color: rgba(255,255,255,0.8); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #48bb78; }
.status-dot.connected { background: #48bb78; }

/* Icon Navigation */
.nav-icons { display: flex; gap: 2px; align-items: center; justify-content: center; }
.nav-icon-item { display: flex; flex-direction: column; align-items: center; padding: 6px 10px; text-decoration: none; border-radius: 8px; transition: all 0.2s; min-width: 50px; }
.nav-icon-item:hover { background: rgba(58,166,185,0.15); }
.nav-icon-item.active { background: rgba(58,166,185,0.25); }
.nav-icon-item .icon { font-size: 20px; line-height: 1; }
.nav-icon-item .label { font-size: 9px; color: rgba(255,255,255,0.7); margin-top: 3px; text-align: center; white-space: nowrap; }
.nav-icon-item:hover .label, .nav-icon-item.active .label { color: #3AA6B9; }

/* CTA button (Prenota) in desktop nav */
.nav-icon-item.nav-cta { background: linear-gradient(135deg, #3AA6B9, #2d8a9a); border-radius: 10px; margin-left: 4px; }
.nav-icon-item.nav-cta .icon { filter: brightness(10); }
.nav-icon-item.nav-cta .label { color: #fff; font-weight: 600; }
.nav-icon-item.nav-cta:hover { background: linear-gradient(135deg, #2d8a9a, #247a88); }
.nav-icon-item.nav-cta:hover .label { color: #fff; }
.nav-icon-item.nav-cta.active { background: linear-gradient(135deg, #2d8a9a, #247a88); }
.nav-icon-item.nav-cta.active .label { color: #fff; }

/* Header button */
.header-btn { font-size: 1rem; text-decoration: none; padding: 6px 8px; border-radius: 6px; transition: background 0.2s; display: flex; align-items: center; justify-content: center; }
.header-btn:hover { background: rgba(255,255,255,0.1); }

/* Legacy nav classes (kept for compatibility) */
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.nav-item { padding: 8px 10px; color: rgba(255,255,255,0.8); text-decoration: none; border-radius: 6px; transition: all 0.2s; white-space: nowrap; font-size: 0.85rem; }
.nav-item:hover { color: #3AA6B9; background: rgba(58,166,185,0.15); }
.nav-item.active { color: #3AA6B9; background: rgba(58,166,185,0.25); }
.nav-dropdown { position: relative; }
.nav-dropdown-menu { position: absolute; top: 100%; left: 0; background: #1e293b; border: 1px solid #334155; border-radius: 8px; min-width: 200px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s; z-index: 1000; }
.nav-dropdown:hover .nav-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-dropdown-item { display: block; padding: 10px 16px; color: #cbd5e1; text-decoration: none; transition: all 0.2s; }
.nav-dropdown-item:hover { background: #334155; color: #3AA6B9; }
.nav-dropdown-item.active { color: #3AA6B9; }

/* ===== MOBILE HAMBURGER MENU ===== */
.mobile-hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.mobile-hamburger:hover { background: rgba(255,255,255,0.1); }
.mobile-hamburger:active { background: rgba(255,255,255,0.2); }

/* Mobile menu overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Slide-in panel */
.mobile-nav-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: linear-gradient(180deg, #1a1f35 0%, #0f1629 100%);
    z-index: 99999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}
.mobile-nav-overlay.open .mobile-nav-panel {
    transform: translateX(0);
}

/* Panel header */
.mobile-nav-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(58,166,185,0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: rgba(58,166,185,0.08);
}
.mobile-nav-header h3 {
    color: #3AA6B9;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.mobile-nav-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 28px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-close:hover { color: white; background: rgba(255,255,255,0.1); }

/* Navigation items */
.mobile-nav-items {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}
.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 15px;
    border-left: 3px solid transparent;
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item:hover,
.mobile-nav-item:active {
    background: rgba(58,166,185,0.12);
    color: #3AA6B9;
}
.mobile-nav-item.active {
    background: rgba(58,166,185,0.15);
    color: #3AA6B9;
    border-left-color: #3AA6B9;
    font-weight: 600;
}
.mobile-nav-item .icon {
    font-size: 22px;
    width: 30px;
    text-align: center;
    flex-shrink: 0;
}

/* CTA item (Prenota) in mobile menu */
.mobile-nav-item.mobile-nav-cta {
    background: linear-gradient(135deg, #3AA6B9, #2d8a9a);
    color: #fff;
    border-radius: 10px;
    margin: 8px 12px 0;
    font-weight: 600;
    border-left-color: transparent;
    padding: 14px 20px;
}
.mobile-nav-item.mobile-nav-cta:hover,
.mobile-nav-item.mobile-nav-cta:active {
    background: linear-gradient(135deg, #2d8a9a, #247a88);
    color: #fff;
}
.mobile-nav-item.mobile-nav-cta.active {
    background: linear-gradient(135deg, #2d8a9a, #247a88);
    color: #fff;
    border-left-color: transparent;
}

/* Panel footer */
.mobile-nav-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.mobile-nav-logout {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: #f56565;
    text-decoration: none;
    font-size: 15px;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-logout:hover,
.mobile-nav-logout:active {
    background: rgba(245,101,101,0.1);
}

/* Footer */
.site-footer {
    background: #0f172a;
    border-top: 1px solid #1e293b;
    padding: 24px 0;
    margin-top: 40px;
    color: #94a3b8;
    font-size: 13px;
}
.footer-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; text-align: center; }
.footer-section { margin-bottom: 12px; }
.footer-section:last-child { margin-bottom: 0; }
.footer-links a { color: #94a3b8; text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: #3AA6B9; }
.footer-divider { margin: 0 8px; color: #334155; }
.social-link { color: #94a3b8; transition: color 0.2s; display: inline-flex; }
.social-link:hover { color: #3AA6B9; }
.footer-legal { font-size: 11px; color: #64748b; }

/* ===== INTERMEDIATE BREAKPOINTS (1024-1280px) ===== */

/* Under 1280px: hide logo text, show only logo icon */
@media (max-width: 1280px) {
    .logo-text { display: none; }
    .logo { gap: 0; }
}

/* Under 1100px: hide nav labels, show only icons */
@media (max-width: 1100px) {
    .nav-icon-item .label { display: none; }
    .nav-icon-item { min-width: 36px; padding: 6px 8px; }
}

/* ===== MOBILE BREAKPOINT ===== */
@media (max-width: 768px) {
    /* Blocca scroll orizzontale (nav panel fuori schermo lo causa su iOS) */
    html, body { overflow-x: hidden !important; }

    /* Header: single row with logo, hamburger, connection */
    .header { height: auto; flex-wrap: nowrap; padding: 10px 12px; align-items: center; }
    .header-left { flex-shrink: 0; }
    .header-center { display: none !important; } /* Hide icon nav on mobile */
    .header-right { flex-shrink: 0; margin-left: auto; }

    .mobile-hamburger { display: flex; align-items: center; justify-content: center; }

    /* Login button compact on mobile */
    .header-login-btn {
        padding: 6px 14px !important;
        font-size: 13px !important;
        margin-right: 4px !important;
        white-space: nowrap;
    }

    .logo { gap: 8px !important; } /* Restore gap hidden at 1280px */
    .logo-text { font-size: 0.95rem; display: inline !important; }
    .logo-img { height: 32px; }
    .connection-status .status-text { display: none; } /* Only show dot on mobile */

    /* Generic container responsiveness */
    .meetings-container, .analytics-container, .tasks-container,
    .quotes-container, .workflows-container, .settings-container,
    .knowledge-container, .calendar-container, .monitoring-container,
    .night-container, .kpi-container, .main-content, .container,
    .page-container, .content-wrapper, .main {
        max-width: 100vw !important;
        padding: 10px !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Grid responsiveness */
    .meetings-grid, .quotes-grid, .tasks-grid, .agents-grid,
    .workflows-grid, .analytics-grid, .knowledge-grid, .cards-grid,
    .kpi-grid, .stats-grid, .charts-grid, .cost-section,
    .two-columns, .form-row, .agent-details-grid,
    .chat-container, .kb-container, .settings-layout,
    .details-grid, .info-grid, .summary-grid, .report-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Card responsiveness */
    .chart-card, .kpi-card, .cost-card, .leaderboard,
    .card, .meeting-card, .task-card, .quote-card {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .chart-container { height: 200px !important; }
    .table-wrapper, .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 100%; }
    .modal { max-width: 95vw !important; margin: 10px !important; }
    .modal-overlay .modal { width: 95vw !important; }
    .nav-dropdown-menu { min-width: auto; max-width: 90vw; }
    .page-header, .section-header { flex-wrap: wrap; gap: 8px; }
    .filter-bar, .filters, .toolbar, .time-filter { flex-wrap: wrap; gap: 6px; }
    .filter-bar select, .filter-bar input { max-width: 45vw; }
    p, span, div, li, td, th { overflow-wrap: break-word; word-wrap: break-word; }

    /* Monitoring: force single column on mobile */
    .monitoring-grid {
        grid-template-columns: 1fr !important;
        padding: 10px !important;
    }
    .monitor-card { grid-column: 1 !important; }

    /* Calendar: stack nav and toggle on mobile */
    .calendar-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px 12px !important;
    }
    .calendar-nav { flex-wrap: wrap !important; gap: 6px !important; }
    .calendar-nav h2 { min-width: auto !important; font-size: 15px !important; }
    .view-toggle { flex-wrap: wrap !important; }

    /* KPI: prevent overflow */
    .metrics-grid, .departments-grid, .kpi-container {
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Agents page mobile fix */
    .agents-container {
        grid-template-columns: 1fr !important;
        height: auto !important;
        padding: 10px !important;
        gap: 15px !important;
    }
    .agents-sidebar {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }
    .agents-list {
        max-height: 50vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y !important;
    }
    /* Agent items: uniformi e compatti su mobile */
    .agent-item {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 10px 12px !important;
    }
    .agent-dept-badge {
        display: none !important;
    }
    .btn-chat-quick {
        display: none !important;
    }
    .agent-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
    }
    #agent-detail, .detail-panel, .agent-panel {
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
    }

    /* Dashboard header (agents.html specific) */
    .dashboard-header {
        flex-wrap: nowrap !important;
        padding: 10px 12px !important;
        gap: 8px;
    }
    .dashboard-header .header-nav {
        display: none !important;
    }
}

/* Phone breakpoint */
@media (max-width: 480px) {
    .header { padding: 8px 10px; }
    .logo-text { font-size: 0.85rem; }
    .logo-img { height: 28px; }

    .meetings-container, .analytics-container, .tasks-container,
    .quotes-container, .workflows-container, .settings-container,
    .knowledge-container, .calendar-container, .monitoring-container,
    .night-container, .kpi-container, .main-content, .container,
    .page-container, .content-wrapper, .main {
        padding: 6px !important;
    }

    .header-login-btn {
        padding: 5px 12px !important;
        font-size: 12px !important;
        margin-right: 2px !important;
    }

    h1, .page-title { font-size: 1.2rem !important; }
    h2 { font-size: 1rem !important; }
    .card, .meeting-card, .task-card, .quote-card { padding: 12px !important; }
    .kpi-card { padding: 14px !important; }
    .kpi-value { font-size: 22px !important; }
    .chart-container { height: 180px !important; }

    .agents-list { max-height: 40vh; }
}
