/* ============================================
   Super News App — Futuristic Glassmorphism UI
   ============================================ */

/* === CSS Variables === */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --bg-glass-active: rgba(255, 255, 255, 0.12);
    --bg-input: rgba(255, 255, 255, 0.06);
    --bg-input-focus: rgba(255, 255, 255, 0.1);

    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.15);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-heading: #f1f5f9;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;

    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --shadow-btn: 0 4px 12px rgba(99, 102, 241, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;

    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
}

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

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

/* Background gradient effect */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    z-index: -1;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, -5%); }
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === Glass Card === */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    transition: var(--transition);
}

.glass:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-hover);
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 24px;
    transition: var(--transition);
}

.glass-card:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glass);
}

/* === Layout === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--border-glass);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 24px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
}

.sidebar-brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
    margin-bottom: 2px;
}

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

.sidebar-link.active {
    background: var(--bg-glass-active);
    color: var(--accent-primary-hover);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-link-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.sidebar-link-badge {
    margin-left: auto;
    background: var(--accent-danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-glass);
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* === Top Bar === */
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-glass-hover);
}

/* === Page Content === */
.page-content {
    padding: 28px;
}

/* === Stat Cards === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    background: var(--bg-glass-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 500;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    color: white;
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-success), #059669);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-danger), #dc2626);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-warning), #d97706);
    color: white;
}

.btn-ghost {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

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

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

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* === Form Elements === */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: inherit;
    transition: var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-error {
    font-size: 11.5px;
    color: var(--accent-danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* === Tables === */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.02);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

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

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.badge-muted {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-glass);
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    min-width: 300px;
    max-width: 420px;
    box-shadow: var(--shadow-glass);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-message {
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
}

.toast-success { border-left: 3px solid var(--accent-success); }
.toast-error { border-left: 3px solid var(--accent-danger); }
.toast-warning { border-left: 3px solid var(--accent-warning); }
.toast-info { border-left: 3px solid var(--accent-info); }

/* === Search Box === */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    transition: var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    color: var(--text-primary);
    padding: 10px 0;
    font-size: 13px;
    width: 100%;
    font-family: inherit;
}

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

.search-box-icon {
    color: var(--text-muted);
    font-size: 16px;
    flex-shrink: 0;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition-fast);
}

.pagination a {
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
}

.pagination a:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--accent-primary);
    color: white;
    border: 1px solid var(--accent-primary);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 13px;
    max-width: 400px;
    margin: 0 auto;
}

/* === Loading Spinner === */
.spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border-glass);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 26, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
}

/* === Avatar === */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* === Tabs === */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: var(--transition-fast);
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

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

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

/* === Utility === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--accent-success); }
.text-danger { color: var(--accent-danger); }
.text-warning { color: var(--accent-warning); }
.text-info { color: var(--accent-info); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hidden { display: none !important; }

/* ============================================
   RESPONSIVE — Mobile First
   ============================================ */

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

    .sidebar.open {
        transform: translateX(0);
    }

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

    .menu-toggle {
        display: flex;
    }

    .page-content {
        padding: 20px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Sidebar overlay on mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .page-content {
        padding: 16px;
    }

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

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-title {
        font-size: 15px;
    }

    .glass-card {
        padding: 16px;
    }

    .modal {
        margin: 10px;
        max-height: 90vh;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 12px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 12.5px;
    }

    .flex-between {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .toast-container {
        left: 10px;
        right: 10px;
    }

    .toast {
        min-width: auto;
    }
}
