/* TimeMachine Platform — Dashboard CSS (Light Theme) */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e0e2e8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #059669;
    --info: #2563eb;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg); color: var(--text);
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: #ffffff; border-right: 1px solid var(--border);
    padding: 20px 0; position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto; z-index: 100; display: flex; flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
}
.sidebar.collapsed {
    width: 0; padding: 0; overflow: hidden; border-right: none;
}
.sidebar .logo { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.sidebar .logo h2 { color: var(--primary); font-size: 18px; white-space: nowrap; }
.sidebar .logo small { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.sidebar nav { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 20px;
    color: var(--text-muted); transition: all 0.2s; font-size: 14px; white-space: nowrap;
}
.sidebar nav a:hover, .sidebar nav a.active { color: var(--text); background: rgba(37,99,235,0.06); text-decoration: none; }
.sidebar nav a.active { border-left: 3px solid var(--primary); color: var(--primary); }
.sidebar nav .divider { height: 1px; background: var(--border); margin: 10px 20px; }
.sidebar .user-info { padding: 15px 20px; border-top: 1px solid var(--border); margin-top: auto; flex-shrink: 0; background: #ffffff; white-space: nowrap; }
.sidebar .user-info .name { font-size: 14px; font-weight: 500; }
.sidebar .user-info .role { font-size: 11px; color: var(--primary); text-transform: uppercase; }

/* Sidebar toggle icon */
.sidebar-toggle-icon {
    background: transparent; border: none;
    cursor: pointer; font-size: 20px; color: var(--text-muted);
    transition: all 0.2s; padding: 4px 8px; border-radius: 4px;
    line-height: 1; display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle-icon:hover { background: rgba(37,99,235,0.1); color: var(--primary); }
.sidebar.collapsed .sidebar-toggle-icon { display: none; }

/* Floating toggle when sidebar is collapsed */
.sidebar-toggle-floating {
    position: fixed; top: 20px; left: 12px; z-index: 200;
    width: 36px; height: 36px; border-radius: 6px;
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: var(--shadow); cursor: pointer;
    display: none; align-items: center; justify-content: center;
    font-size: 18px; color: var(--text-muted); transition: all 0.2s;
}
.sidebar-toggle-floating:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
body.sidebar-collapsed .sidebar-toggle-floating { display: flex; }

.main { margin-left: 240px; flex: 1; padding: 100px 30px 30px 30px; min-height: 100vh; transition: margin-left 0.25s ease; }
body.sidebar-collapsed .main { margin-left: 0; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 600; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: 12px; font-size: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.stat-card .value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px;
    transition: all 0.2s; font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
input, select, textarea {
    width: 100%; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr:hover { background: #f5f6fa; }
tbody tr:nth-child(even) { background: #f9fafb; }
tbody tr:nth-child(even):hover { background: #f0f1f5; }

/* Badges */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px;
    font-weight: 600; text-transform: uppercase;
}
.badge-trial { background: #dbeafe; color: #1d4ed8; }
.badge-active { background: #d1fae5; color: #047857; }
.badge-expired { background: #fef3c7; color: #b45309; }
.badge-suspended { background: #fee2e2; color: #b91c1c; }
.badge-banned { background: #fecaca; color: #991b1b; }
.badge-super_admin { background: #dbeafe; color: var(--primary); }
.badge-admin { background: #ede9fe; color: #7c3aed; }
.badge-user { background: #f3f4f6; color: #6b7280; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; cursor: pointer; color: var(--text-muted); font-size: 14px;
    border-bottom: 2px solid transparent; transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Modal */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 90%; max-width: 500px; box-shadow: 0 4px 24px rgba(0,0,0,0.12); }
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; }
.toast {
    background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 20px; margin-bottom: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Notifications bell */
.notification-bell { position: relative; cursor: pointer; }
.notification-bell .count {
    position: absolute; top: -4px; right: -4px; background: var(--danger);
    color: #fff; font-size: 10px; width: 16px; height: 16px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* Auth pages */
.auth-container {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: var(--bg);
}
.auth-box {
    background: #ffffff; border: 1px solid var(--border); border-radius: 12px;
    padding: 40px; width: 400px; max-width: 90%; box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-box h1 { text-align: center; margin-bottom: 8px; color: var(--primary); }
.auth-box .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.auth-box .btn { width: 100%; justify-content: center; padding: 12px; }
.auth-box .footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 0; padding: 0; overflow: hidden; border-right: none; }
    .sidebar-toggle { left: 8px; }
    body:not(.sidebar-collapsed) .sidebar-toggle { left: 8px; }
    body.sidebar-open .sidebar { width: 240px; padding: 20px 0; overflow-y: auto; border-right: 1px solid var(--border); }
    body.sidebar-open .sidebar-toggle { left: 244px; }
    .main { margin-left: 0; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Empty state */
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Top Header (Profilo + Logout) ─────────────────────── */
.top-header {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 30px;
    gap: 12px;
    transition: left 0.25s ease;
}
body.sidebar-collapsed .top-header {
    left: 0;
}
.top-header .user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    text-decoration: none;
}
.top-header .user-profile:hover {
    background: var(--bg);
    text-decoration: none;
}
.top-header .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}
.top-header .user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.top-header .user-name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}
.top-header .user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1.2;
}
.top-header .btn-logout {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.top-header .btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
