/* ============================================
   XTREAM MANAGER — Dark Theme with Red Accents
   ============================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
    --bg-body: #0d0d0f;
    --bg-surface: #151518;
    --bg-surface-2: #1c1c21;
    --bg-surface-3: #232329;
    --bg-hover: #2a2a32;
    --border: #2a2a32;
    --border-focus: #dc2626;

    --text-primary: #f0f0f4;
    --text-secondary: #9a9aad;
    --text-muted: #6b6b80;

    --red-500: #dc2626;
    --red-600: #b91c1c;
    --red-700: #991b1b;
    --red-400: #f87171;
    --red-glow: rgba(220, 38, 38, 0.15);
    --red-glow-strong: rgba(220, 38, 38, 0.3);

    --green-500: #22c55e;
    --yellow-500: #eab308;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
    --shadow-red: 0 0 20px var(--red-glow);

    --sidebar-width: 260px;
    --topbar-height: 60px;

    --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
}

a { color: var(--red-400); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--red-500); }

code {
    background: var(--bg-surface-3);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: var(--red-400);
}

/* --- App Shell --- */
.app-shell {
    display: flex;
    min-height: 100dvh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100dvh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    font-size: 1.6rem;
    color: var(--red-500);
    filter: drop-shadow(0 0 6px var(--red-glow-strong));
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--red-400), var(--red-600));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition);
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-icon { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 4px;
}

.user-avatar, .user-avatar-sm {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--red-600), var(--red-500));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--shadow-red);
}

.user-avatar-sm { width: 28px; height: 28px; font-size: 0.75rem; }

.user-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-link { color: var(--text-muted) !important; }
.logout-link:hover { color: var(--red-400) !important; background: var(--red-glow); }

/* --- Sidebar overlay (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 90;
    backdrop-filter: blur(2px);
}

/* --- Main Area --- */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-weight: 600;
    font-size: 1.05rem;
    display: none;
}

.topbar-spacer { flex: 1; }

.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.3rem;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.hamburger:hover { background: var(--bg-hover); border-color: var(--red-500); }

/* --- Content --- */
.content {
    flex: 1;
    padding: 28px 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.content--fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    max-width: 100%;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 2px;
}

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

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--red-600);
    box-shadow: var(--shadow-red);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 2rem;
    width: 52px; height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--red-glow);
    border-radius: var(--radius-md);
    color: var(--red-400);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Quick Actions --- */
.quick-actions { margin-bottom: 32px; }
.quick-actions h2 { font-size: 1.15rem; margin-bottom: 14px; }

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 500;
    transition: all var(--transition);
}

.action-card:hover {
    border-color: var(--red-500);
    background: var(--bg-surface-2);
    box-shadow: var(--shadow-red);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.action-icon { font-size: 1.4rem; color: var(--red-400); }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 18px; }

/* --- Data Table --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table thead {
    background: var(--bg-surface-2);
}

.data-table th {
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.url-cell {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }

.actions-cell {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.badge-admin {
    background: var(--red-glow);
    color: var(--red-400);
    border: 1px solid var(--red-700);
}

.badge-user {
    background: var(--bg-surface-3);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--red-600), var(--red-500));
    color: #fff;
    box-shadow: var(--shadow-red);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--red-500), var(--red-400));
    box-shadow: 0 0 30px var(--red-glow-strong);
    transform: translateY(-1px);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-danger {
    background: rgba(220,38,38,.15);
    color: var(--red-400);
    border: 1px solid var(--red-700);
}

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

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* --- Forms --- */
.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 560px;
}

.danger-card { border-color: var(--red-700); }

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition);
    outline: none;
    font-family: inherit;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
    border-color: var(--red-500);
    box-shadow: 0 0 0 3px var(--red-glow);
    background: var(--bg-surface-3);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--red-500);
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* --- Confirm / Delete --- */
.confirm-message {
    text-align: center;
    padding: 20px 0 28px;
}

.confirm-icon {
    font-size: 2.6rem;
    color: var(--red-400);
    margin-bottom: 12px;
}

.confirm-message p { margin-bottom: 6px; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-danger {
    background: rgba(220,38,38,.1);
    border: 1px solid var(--red-700);
    color: var(--red-400);
}

/* --- Login --- */
.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg), var(--shadow-red);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    display: inline-block;
    font-size: 2.8rem;
    color: var(--red-500);
    filter: drop-shadow(0 0 12px var(--red-glow-strong));
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--red-400), var(--text-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =====================
   RESPONSIVE BREAKPOINTS
   ===================== */

/* --- Tablet (< 1024px) --- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-overlay { display: block; }

    .main-area {
        margin-left: 0;
    }

    .hamburger { display: flex; }
    .topbar-title { display: block; }

    .content { padding: 20px; }
}

/* --- Mobile (< 640px) --- */
@media (max-width: 640px) {
    html { font-size: 15px; }

    .content { padding: 16px 14px; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 { font-size: 1.35rem; }

    .stats-grid { grid-template-columns: 1fr; }

    .login-card { padding: 28px 20px; border-radius: var(--radius-lg); }

    .form-card { padding: 20px 16px; }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn { width: 100%; }

    /* Card-style table on mobile */
    .data-table thead { display: none; }

    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
        position: relative;
    }

    .data-table td {
        padding: 4px 0;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        white-space: normal;
    }

    .data-table td::before {
        content: attr(data-label);
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        margin-right: 12px;
    }

    .actions-cell {
        justify-content: flex-end;
        padding-top: 8px !important;
        margin-top: 6px;
        border-top: 1px solid var(--border) !important;
    }

    .url-cell { max-width: 160px; }
}

/* --- Very small (< 380px) --- */
@media (max-width: 380px) {
    html { font-size: 14px; }
    .login-card { padding: 24px 16px; }
    .sidebar { width: 240px; }
    .stat-card { padding: 16px; }
}

/* --- Accessibility / Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* --- Focus visible --- */
:focus-visible {
    outline: 2px solid var(--red-500);
    outline-offset: 2px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb {
    background: var(--bg-surface-3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Selection --- */
::selection {
    background: var(--red-glow-strong);
    color: var(--text-primary);
}
