@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Sophisticated Slate & Indigo Palette */
    --bg-main: #0a0c10;
    --bg-surface: #12151c;
    --bg-card: #1a1e26;
    --bg-accent: #1e2430;

    --primary: #818cf8;
    /* Soft Indigo */
    --primary-glow: rgba(129, 140, 248, 0.4);
    --secondary: #2dd4bf;
    /* Crisp Teal */

    --text-heading: #ffffff;
    --text-body: #e2e8f0;
    --text-dim: #94a3b8;

    --border: #262c3a;
    --border-bright: #334155;

    --success: #10b981;
    --error: #f43f5e;
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-main: 0 4px 20px -5px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-body);
    min-height: 100vh;
    padding: 1.5rem;
    line-height: 1.6;
    background-image:
        radial-gradient(circle at 15% 15%, rgba(129, 140, 248, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(45, 212, 191, 0.05) 0%, transparent 40%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-heading);
}

h1 span {
    color: var(--primary);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.logout-link {
    color: var(--error);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.8;
    transition: var(--transition);
}

.logout-link:hover {
    opacity: 1;
    text-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

/* Tab Navigation */
.nav-tabs {
    background: var(--bg-surface);
    padding: 0.4rem;
    border-radius: var(--radius-lg);
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
    width: fit-content;
    border: 1px solid var(--border);
}

.nav-tab {
    padding: 0.75rem 1.75rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    color: var(--text-dim);
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-tab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-main);
    border: 1px solid var(--border-bright);
}

.nav-tab:hover:not(.active) {
    color: var(--text-heading);
    background: rgba(255, 255, 255, 0.03);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-bright);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
}

.stat-card h3 {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-heading);
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    opacity: 0.3;
}

/* Table Section */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.search-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    width: 320px;
    font-family: inherit;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.per-page-select {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    cursor: pointer;
}

.main-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    padding: 1.25rem 1rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-body);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

tr:last-child td {
    border-bottom: none;
}

/* User Management Extras */
.badge-status {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-status-inactive {
    background: rgba(244, 63, 94, 0.1);
    color: var(--error);
}

.api-key-box {
    background: var(--bg-accent);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--primary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.api-key-box:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

/* Buttons */
.btn-preview {
    background: var(--bg-accent);
    color: var(--text-heading);
    border: 1px solid var(--border-bright);
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition);
}

.btn-preview:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px -5px var(--primary-glow);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 5, 8, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-bright);
    width: 100%;
    max-width: 1100px;
    border-radius: var(--radius-lg);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.6);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

pre {
    background: #000;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    color: #10b981;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: white;
}

/* Pagination */
.pagination-container {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.pagination-btn {
    background: var(--bg-accent);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}

.pagination-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-btn:hover:not(.active):not(:disabled) {
    border-color: var(--border-bright);
    color: var(--text-heading);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}