/* ==========================================
   ADBBOT PRO DASHBOARD - DESIGN SYSTEM
   ========================================== */

:root {
    --bg-dark: #0a0d14;
    --bg-card: #121622;
    --bg-card-hover: #191f30;
    --bg-sidebar: #0e111a;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.16);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.3);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.3);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    
    --font-ui: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --sidebar-width: 260px;
    --terminal-height: 280px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* --- CUSTOM SCROLLBARS --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: var(--border-highlight);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- APP LAYOUT --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    padding-bottom: 44px; /* Spazio per terminal header minimizzato */
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    backdrop-filter: blur(20px);
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.logo-text h1 {
    font-family: var(--font-ui);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-cyan);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 20px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.15), rgba(139, 92, 246, 0.1));
    border-color: rgba(6, 182, 212, 0.3);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.nav-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--accent-cyan);
}

.nav-tag {
    margin-left: auto;
    font-size: 11px;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-emerald);
    font-weight: 500;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.footer-time {
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px 240px 40px; /* Spazio sotto per terminale */
    position: relative;
}

.view-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.view-header h2 {
    font-family: var(--font-ui);
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.view-header h2 i {
    color: var(--accent-cyan);
}

.view-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.view-header code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--accent-emerald);
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-cyan-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-cyan-glow);
}

.btn-emerald {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-emerald-glow);
}
.btn-emerald:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-emerald-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}
.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 10px;
    width: 38px;
    height: 38px;
    justify-content: center;
}

/* --- STATS CARDS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-highlight);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.stat-icon.yellow { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-family: var(--font-ui);
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- SECTION TITLES & BADGES --- */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title h3 {
    font-family: var(--font-ui);
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}
.badge-info { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

/* --- DEVICES GRID (/status) --- */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    overflow: hidden;
}

.device-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--text-muted);
}
.device-card.online::before { background: var(--accent-emerald); box-shadow: 0 0 10px var(--accent-emerald); }
.device-card.unauthorized::before { background: var(--accent-yellow); }

.device-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.device-id {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.device-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}
.device-badge.online { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.device-badge.offline { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.device-badge.unauthorized { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }

.device-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.device-body div {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- FILTER BAR (/dlaccounts) --- */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 14px 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    flex: 1;
    min-width: 250px;
}

.search-box i {
    color: var(--text-muted);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 14px;
    width: 100%;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.select-filter {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* --- DATA TABLE --- */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.data-table th {
    background: rgba(0, 0, 0, 0.25);
    padding: 14px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    font-family: var(--font-ui);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.data-table code {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.status-yes {
    color: var(--accent-emerald);
    font-weight: 600;
    background: rgba(16, 185, 129, 0.15);
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-block;
    font-size: 11px;
}

.status-no {
    color: var(--text-muted);
    font-size: 12px;
}

/* --- INFOCARTA DEVICES & ACCOUNTS (/infocarta) --- */
.infocarta-devices-list {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.info-dev-tab {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-dev-tab:hover {
    border-color: var(--border-highlight);
    background: var(--bg-card-hover);
}

.info-dev-tab.active {
    border-color: var(--accent-cyan);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(139, 92, 246, 0.1));
    box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.info-dev-tab h4 {
    font-family: var(--font-mono);
    font-size: 15px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.info-dev-tab span {
    font-size: 12px;
    color: var(--text-secondary);
}

.infocarta-accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.card-account-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
}

.card-account-item:hover {
    border-color: var(--border-highlight);
}

.card-acc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.card-details-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.card-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
}

.card-detail-row span.val {
    font-family: var(--font-mono);
    color: #fff;
    font-weight: 500;
}
.card-detail-row span.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* --- TERMINAL DOCK (BOTTOM CENTER) --- */
.terminal-dock {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--terminal-height);
    background: #0d1017;
    border-top: 2px solid var(--border-highlight);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.terminal-dock.minimized {
    height: 44px;
}

.terminal-header {
    height: 44px;
    background: #141824;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.terminal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.terminal-title i {
    color: var(--accent-cyan);
}

.status-badge {
    font-size: 10px;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}
.status-badge.stopped { background: rgba(100, 116, 139, 0.2); color: var(--text-secondary); }
.status-badge.running { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); box-shadow: 0 0 10px var(--accent-emerald-glow); }
.status-badge.error { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

.terminal-tabs {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.term-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 14px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.term-tab.active {
    background: var(--bg-card-hover);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.terminal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.terminal-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 20px;
    background: #080a0f;
    font-family: var(--font-mono);
    font-size: 12px;
}

.log-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log-line {
    display: flex;
    gap: 12px;
    line-height: 1.4;
    word-break: break-all;
}

.log-time {
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
}

.log-line.info .log-text { color: #e2e8f0; }
.log-line.success .log-text { color: var(--accent-emerald); font-weight: 600; }
.log-line.error .log-text { color: var(--accent-red); }
.log-line.warn .log-text { color: var(--accent-yellow); }

/* --- MODALE --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-family: var(--font-ui);
    font-size: 18px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}
.btn-close-modal:hover { color: #fff; }

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: var(--font-ui);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
}

.input-with-icon input, .input-disabled {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px 10px 40px;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-disabled {
    padding-left: 14px;
    color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.03);
    cursor: not-allowed;
}

.input-with-icon input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.footer-right {
    display: flex;
    gap: 10px;
}

/* --- UTILITY CLASSES --- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 24px; }
.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    grid-column: 1 / -1;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 900px) {
    .sidebar { width: 70px; }
    .logo-text, .sidebar-nav span, .sidebar-footer span:not(.pulse-dot), .nav-tag { display: none; }
    .nav-item { justify-content: center; padding: 14px 0; }
    .nav-item i { font-size: 20px; }
    .main-content { padding: 20px 20px 240px 20px; }
    .terminal-dock { left: 70px; }
}
