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

:root {
    --bg-primary: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --bg-sidebar: #111111;
    --bg-input: #1e1e1e;
    --text-primary: #ffffff;
    --text-muted: #888888;
    --text-dim: #555555;
    --accent: #00B894;
    --accent-cyan: #00CEC9;
    --gradient: linear-gradient(135deg, #00B894, #00CEC9);
    --error: #E74C3C;
    --warning: #FF9800;
    --border: #2a2a2a;
    --border-light: #333333;
    --sidebar-width: 240px;
    --header-height: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ===== Login Overlay ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    margin: 0 16px;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-text {
    display: block;
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.form-group input:focus {
    border-color: var(--accent);
}

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

.login-error {
    color: var(--error);
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
    text-align: center;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
}

.btn-login:hover {
    opacity: 0.9;
}

.btn-login:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

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

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.brand-text {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

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

.nav-item.active {
    background: rgba(0, 184, 148, 0.1);
    color: var(--accent);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.btn-logout {
    padding: 8px 18px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-logout:hover {
    border-color: var(--error);
    color: var(--error);
}

/* ===== Views ===== */
.view {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
}

.stat-card-wide {
    grid-column: span 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Tables ===== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table thead {
    background: rgba(255, 255, 255, 0.03);
}

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

.data-table td {
    padding: 14px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

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

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

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

/* Role dropdown */
.role-select {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}

.role-select:focus {
    border-color: var(--accent);
}

.role-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-ok {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent);
}

.status-redirect {
    background: rgba(255, 152, 0, 0.15);
    color: var(--warning);
}

.status-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--error);
}

/* Method badges */
.method-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
}

.method-GET    { background: rgba(0, 184, 148, 0.15); color: var(--accent); }
.method-POST   { background: rgba(52, 152, 219, 0.15); color: #3498DB; }
.method-PUT    { background: rgba(255, 152, 0, 0.15);  color: var(--warning); }
.method-DELETE { background: rgba(231, 76, 60, 0.15);  color: var(--error); }
.method-PATCH  { background: rgba(155, 89, 182, 0.15); color: #9B59B6; }

/* Path text */
.path-text {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Logs Toolbar ===== */
.logs-toolbar {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--border-light);
    border-radius: 11px;
    position: relative;
    transition: background var(--transition);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--accent);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(18px);
}

/* ===== Empty & Loading States ===== */
.empty-state,
.loading-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.loading-state {
    color: var(--text-dim);
}

/* ===== Toast Notifications ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    z-index: 2000;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    animation-fill-mode: forwards;
}

.toast-success { background: var(--accent); }
.toast-error   { background: var(--error); }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -var(--sidebar-width);
        z-index: 100;
        height: 100%;
        transition: left var(--transition);
    }

    .sidebar.open {
        left: 0;
    }

    .main {
        width: 100%;
    }

    .view {
        padding: 20px 16px;
    }

    .header {
        padding: 0 16px;
    }

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

    .data-table {
        font-size: 13px;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
