/* ===================================================
   A10 Platform - Main Stylesheet
   Layout a 3 pannelli con navigazione dinamica
   =================================================== */

/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colori principali */
    --sidebar-bg: #3355cc;
    --sidebar-width: 60px;
    --panel2-bg: #e8edf5;
    --panel2-width: 240px;
    --panel3-bg: #ffffff;
    --tab-bar-bg: #f5f5f5;

    /* Colori accento */
    --accent-primary: #e6a817;
    --accent-secondary: #9ca3af;
    --accent-hover: #2a47b0;
    --accent-active: #1e3a8a;

    /* Colori testo */
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-light: #ffffff;
    --text-muted: #9ca3af;

    /* Colori stato */
    --status-online: #22c55e;
    --status-offline: #ef4444;
    --status-away: #f59e0b;

    /* Ombre */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);

    /* Transizioni */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--panel3-bg);
}

/* === APP CONTAINER === */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ===================================================
   PANEL 1: Sidebar principale (60px) - Sempre visibile
   =================================================== */
.panel-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    z-index: 100;
    position: relative;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

/* Avatar utente */
.sidebar-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
    cursor: pointer;
}

.avatar-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 18px;
    transition: background var(--transition-fast);
}

.sidebar-avatar:hover .avatar-icon {
    background: rgba(255,255,255,0.25);
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
}

.status-indicator.online { background: var(--status-online); }
.status-indicator.offline { background: var(--status-offline); }
.status-indicator.away { background: var(--status-away); }

/* Navigazione sidebar - icone servizi */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 0 8px;
}

.sidebar-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
    position: relative;
    color: var(--text-light);
    background: transparent;
}

.sidebar-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.05);
}

.sidebar-btn.active {
    background: rgba(255,255,255,0.2);
    box-shadow: inset 3px 0 0 var(--text-light);
}

/* Colori diversi per le icone dei servizi (come nel PDF) */
.sidebar-btn[data-color="blue"] {
    background: rgba(147, 180, 230, 0.5);
}
.sidebar-btn[data-color="orange"] {
    background: var(--accent-primary);
}
.sidebar-btn[data-color="white"] {
    background: rgba(255,255,255,0.85);
    color: var(--text-primary);
}
.sidebar-btn[data-color="gray"] {
    background: rgba(200,200,210,0.6);
}

.sidebar-btn[data-color="blue"]:hover { background: rgba(147, 180, 230, 0.7); }
.sidebar-btn[data-color="orange"]:hover { background: #d4960f; }
.sidebar-btn[data-color="white"]:hover { background: rgba(255,255,255,0.95); }
.sidebar-btn[data-color="gray"]:hover { background: rgba(200,200,210,0.8); }

.sidebar-btn[data-color="blue"].active,
.sidebar-btn[data-color="orange"].active,
.sidebar-btn[data-color="white"].active,
.sidebar-btn[data-color="gray"].active {
    box-shadow: inset 3px 0 0 var(--text-light), 0 2px 8px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

/* Tooltip per icone sidebar */
.sidebar-btn::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--text-primary);
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 200;
}

.sidebar-btn:hover::after {
    opacity: 1;
}

/* Settings button */
#btnSettings {
    background: transparent;
    opacity: 0.7;
}
#btnSettings:hover {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}

/* Logo A10 */
.sidebar-logo {
    padding: 8px 0 4px;
}

.logo-text {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-light);
    letter-spacing: -0.5px;
    font-style: italic;
}

/* ===================================================
   PANEL 2: Pannello secondario (240px) - Toggle
   =================================================== */
.panel-secondary {
    width: 240px;    /* Default, sovrascritta da JS per servizio */
    min-width: 240px;
    max-width: 800px;
    height: 100vh;
    background: var(--panel2-bg);
    border-right: 1px solid #d1d5db;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-normal);
    overflow: hidden;
    z-index: 50;
}

.panel-secondary.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
    opacity: 0;
    padding: 0;
    overflow: hidden;
}

.panel2-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #d1d5db;
    min-height: 52px;
}

.panel2-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.panel2-back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px 4px 0;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.panel2-back-btn:hover {
    color: var(--primary);
}

.panel2-collapse {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.panel2-collapse:hover {
    background: rgba(0,0,0,0.08);
    color: var(--text-primary);
}

.panel2-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Modalità supporto nel pannello 2 */
.panel2-support-frame {
    flex: 1;
    min-height: 0;
    padding: 0 4px 4px;
}

/* Elementi menu nel pannello 2 */
.panel2-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-primary);
    font-size: 13px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.panel2-menu-item:hover {
    background: rgba(0,0,0,0.06);
}

.panel2-menu-item.active {
    background: rgba(51,85,204,0.1);
    color: var(--sidebar-bg);
    font-weight: 500;
}

.panel2-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.panel2-menu-item.active i {
    color: var(--sidebar-bg);
}

.panel2-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 14px 16px 6px;
}

.panel2-divider {
    height: 1px;
    background: #d1d5db;
    margin: 8px 16px;
}

/* Notifiche nel pannello 2 */
.panel2-notifications {
    padding: 6px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: calc(100vh - 400px);
}
.notif-loading {
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: 14px;
}
.notif-empty {
    text-align: center;
    padding: 16px 8px;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.notif-empty i {
    font-size: 18px;
    opacity: 0.4;
}
.notif-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-left: 3px solid #2563eb;
}
.notif-card:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37,99,235,0.1);
}
.notif-card.notif-cat-alert  { border-left-color: #f59e0b; }
.notif-card.notif-cat-warning { border-left-color: #ef4444; }
.notif-card.notif-cat-success { border-left-color: #16a34a; }
.notif-card.notif-cat-system  { border-left-color: #6b7280; }
.notif-card.notif-cat-service { border-left-color: #8b5cf6; }

.notif-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.notif-category {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #2563eb;
    background: #eff6ff;
    padding: 1px 6px;
    border-radius: 4px;
}
.notif-cat-alert .notif-category  { color: #f59e0b; background: #fffbeb; }
.notif-cat-warning .notif-category { color: #ef4444; background: #fef2f2; }
.notif-cat-success .notif-category { color: #16a34a; background: #f0fdf4; }
.notif-cat-system .notif-category  { color: #6b7280; background: #f3f4f6; }
.notif-cat-service .notif-category { color: #8b5cf6; background: #f5f3ff; }

.notif-time {
    font-size: 10px;
    color: #9ca3af;
    white-space: nowrap;
}
.notif-card-title {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    line-height: 1.3;
}

/* ===================================================
   PANEL 3: Area contenuto principale - Multitab
   =================================================== */
.panel-main {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel3-bg);
    transition: margin-left var(--transition-normal);
}

/* Tab bar */
.tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--tab-bar-bg);
    border-bottom: 1px solid #e5e7eb;
    min-height: 44px;
    padding: 6px 10px 0;
}

.tab-bar.hidden {
    display: none;
}

.tab-list {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    overflow-x: auto;
    flex: 1;
    padding-bottom: 0;
}

.tab-list::-webkit-scrollbar {
    height: 3px;
}
.tab-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    position: relative;
    min-width: 100px;
    max-width: 220px;
    overflow: hidden;
}
.tab-item .tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.tab-item:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
}

.tab-item.active {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.tab-item .tab-close {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.tab-item:hover .tab-close,
.tab-item.active .tab-close {
    opacity: 0.7;
}

.tab-item .tab-close:hover {
    opacity: 1;
    background: rgba(0,0,0,0.15);
}

.tab-item.inactive-tab {
    background: var(--accent-secondary);
    color: #fff;
}

/* Dot colore servizio nella tab */
.tab-service-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-left: 10px;
    padding-bottom: 6px;
}

.tab-action-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.tab-action-btn:hover {
    background: rgba(0,0,0,0.08);
    color: var(--text-primary);
}

/* Tab content area */
.tab-content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-pane {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: auto;
}

.tab-pane.active {
    display: block;
}

/* Iframe per servizi esterni */
.tab-pane iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Welcome screen */
.welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8faff 0%, #e8edf8 100%);
}

.welcome-inner {
    text-align: center;
    padding: 40px;
}

.welcome-logo {
    font-size: 72px;
    font-weight: 900;
    font-style: italic;
    color: var(--sidebar-bg);
    margin-bottom: 20px;
    letter-spacing: -2px;
}

.welcome-inner h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.welcome-inner p {
    font-size: 15px;
    color: var(--text-secondary);
}

/* ===================================================
   SERVICE CONTENT STYLES (per contenuti servizi interni)
   =================================================== */
.service-page {
    padding: 24px;
    max-width: 1200px;
}

.service-page h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.service-page p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.service-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.service-card {
    background: #f8faff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition-fast);
}

.service-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.service-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.service-card p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===================================================
   SCROLLBAR PERSONALIZZATA
   =================================================== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c1c7d0;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a1a7b0;
}

/* ===================================================
   RESPONSIVE / ANIMAZIONI
   =================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-pane.active {
    animation: fadeIn 0.2s ease;
}

/* Notifica badge */
.sidebar-btn .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ===================================================
   SETTINGS PANEL CONTENT
   =================================================== */
.settings-section {
    padding: 16px;
}

.settings-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: #d1d5db;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle-switch.active {
    background: var(--sidebar-bg);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition-fast);
}

.toggle-switch.active::after {
    transform: translateX(16px);
}

/* ===================================================
   LOGIN SCREEN (App Frontend)
   =================================================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #2a3f8f 50%, #3355cc 100%);
    z-index: 1000;
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    font-size: 48px;
    font-weight: 900;
    font-style: italic;
    color: var(--sidebar-bg);
    letter-spacing: -2px;
    margin-bottom: 8px;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 28px;
}

.login-field {
    text-align: left;
    margin-bottom: 18px;
}

.login-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
    outline: none;
}

.login-field input:focus {
    border-color: var(--sidebar-bg);
    box-shadow: 0 0 0 3px rgba(51, 85, 204, 0.15);
}

.login-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===================================================
   SIDEBAR: Stili dinamici per servizi dal backend
   =================================================== */
/* Per i servizi caricati dal backend, il colore è impostato
   via CSS custom property --service-color in JS */
.sidebar-btn[data-service]:not([data-color]) {
    background: transparent;
}

/* Avatar con iniziali utente */
.avatar-icon span {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

/* Sidebar vuota */
.sidebar-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
}
