/* ============================================
   TwitchLogger — Dark Theme Design System
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    /* Core palette */
    --bg-primary: #0e0e10;
    --bg-secondary: #18181b;
    --bg-tertiary: #1f1f23;
    --bg-elevated: #26262c;
    --bg-hover: #303036;

    /* Twitch purple gradient */
    --accent-primary: #9147ff;
    --accent-secondary: #772ce8;
    --accent-glow: rgba(145, 71, 255, 0.15);
    --accent-soft: rgba(145, 71, 255, 0.08);

    /* Text */
    --text-primary: #efeff1;
    --text-secondary: #adadb8;
    --text-muted: #7a7a85;
    --text-link: #bf94ff;

    /* Semantic */
    --success: #00c853;
    --success-bg: rgba(0, 200, 83, 0.1);
    --warning: #ffab40;
    --warning-bg: rgba(255, 171, 64, 0.1);
    --danger: #ef5350;
    --danger-bg: rgba(239, 83, 80, 0.1);
    --info: #42a5f5;
    --info-bg: rgba(66, 165, 245, 0.1);

    /* Layout */
    --sidebar-width: 260px;
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --border-radius-lg: 12px;
    --border-color: #2f2f35;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-primary);
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

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

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

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

.nav-link:hover svg {
    opacity: 1;
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-primary);
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

.nav-link.active svg {
    opacity: 1;
    color: var(--accent-primary);
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.75rem 0;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-logout {
    width: 100%;
    padding: 0.4rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

/* ---------- Main Content ---------- */
.content-with-sidebar {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: calc(100vw - var(--sidebar-width));
}

.content-full {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

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

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.stat-highlight {
    border-color: var(--warning);
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--warning); }
    50% { border-color: rgba(255, 171, 64, 0.3); }
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.channels { background: var(--accent-glow); color: var(--accent-primary); }
.stat-icon.total { background: var(--info-bg); color: var(--info); }
.stat-icon.users { background: var(--success-bg); color: var(--success); }
.stat-icon.pending { background: var(--warning-bg); color: var(--warning); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    display: block;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: block;
}

/* ---------- Tables ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(47, 47, 53, 0.5);
    font-size: 0.875rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- Message List ---------- */
.message-list {
    display: flex;
    flex-direction: column;
}

.message-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    transition: background var(--transition-fast);
}

.message-row:hover {
    background: var(--bg-hover);
}

.message-deleted {
    opacity: 0.4;
}

.message-time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 60px;
}

.message-channel {
    font-weight: 600;
    color: var(--accent-primary);
    flex-shrink: 0;
    min-width: 100px;
}

.message-sender {
    font-weight: 600;
    color: var(--info);
    flex-shrink: 0;
    min-width: 100px;
}

.message-content {
    color: var(--text-primary);
    word-break: break-word;
    flex: 1;
}

.log-view .message-row {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-sm {
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
}

.badge-admin { background: var(--danger-bg); color: var(--danger); }
.badge-moderator { background: var(--accent-glow); color: var(--accent-primary); }
.badge-user { background: var(--info-bg); color: var(--info); }
.badge-success, .badge-active { background: var(--success-bg); color: var(--success); }
.badge-warning, .badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-danger, .badge-rejected, .badge-disabled { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: rgba(122, 122, 133, 0.15); color: var(--text-muted); }
.badge-audit { background: var(--bg-elevated); color: var(--text-secondary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--accent-primary);
    color: white;
    text-decoration: none;
}

.btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: white;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

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

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

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #00b34a;
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-warning {
    background: var(--warning);
    color: var(--bg-primary);
}

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

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

.btn-twitch {
    background: var(--accent-primary);
    color: white;
    font-size: 1rem;
    padding: 0.85rem 2rem;
    border-radius: var(--border-radius);
    width: 100%;
    justify-content: center;
}

.btn-twitch:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

/* ---------- Forms ---------- */
.form-input {
    padding: 0.55rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-family);
    transition: border-color var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.form-input-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
}

.form-select {
    appearance: none;
    padding: 0.55rem 2rem 0.55rem 0.85rem;
    background: var(--bg-tertiary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7a85' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-family);
    cursor: pointer;
}

.form-select-sm {
    padding: 0.35rem 1.75rem 0.35rem 0.6rem;
    font-size: 0.8rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.search-form .form-input {
    flex: 1;
    min-width: 200px;
}

.filter-form {
    flex: 1;
}

.filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-row .form-input,
.filter-row .form-select {
    min-width: 120px;
}

/* ---------- Filter Tabs ---------- */
.filter-tabs {
    display: flex;
    gap: 0;
}

.tab {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.result-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ---------- Auth Pages ---------- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
}

.auth-icon.pending { color: var(--warning); }
.auth-icon.denied { color: var(--danger); }

.auth-info {
    text-align: left;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.auth-info p + p {
    margin-top: 0.75rem;
}

.auth-footer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auth-note {
    margin-top: 0.5rem;
    color: var(--warning);
    font-weight: 500;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(0, 200, 83, 0.3);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 83, 80, 0.3);
    color: var(--danger);
}

/* ---------- Utilities ---------- */
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.old-names { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }
.channel-name { font-weight: 600; color: var(--accent-primary); }

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .content-with-sidebar {
        margin-left: 220px;
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        transition: transform var(--transition-normal);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .content-with-sidebar {
        margin-left: 0;
        padding: 1rem;
    }
    .filter-row {
        flex-direction: column;
    }
    .filter-row .form-input,
    .filter-row .form-select {
        width: 100%;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}