:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-sidebar: #0f3460;
    --bg-topbar: #0f3460;
    --bg-hover: #1a4080;
    --bg-active: #e94560;
    --bg-card: #16213e;
    --bg-input: #1a1a2e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-active: #ffffff;
    --border-color: #2a2a4a;
    --accent: #e94560;
    --success: #4caf50;
    --error: #f44336;
    --sidebar-width: 260px;
    --topbar-height: 50px;
    --transition-speed: 0.2s;
}

/* ── Reset & Base ── */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Topbar ── */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

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

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-active);
    letter-spacing: 0.5px;
}

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

.topbar-username {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-logout {
    font-size: 0.875rem;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-speed);
}

.btn-logout:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

/* ── Hamburger ── */

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 22px;
    height: 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.hamburger span {
    display: block;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: background var(--transition-speed);
}

/* ── Sidebar ── */

.sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--bg-sidebar);
    overflow-y: auto;
    z-index: 999;
    transition: transform var(--transition-speed);
}

.sidebar-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-speed);
}

.sidebar-section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-section-arrow {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform var(--transition-speed);
}

.sidebar-section-header.collapsed .sidebar-section-arrow {
    transform: rotate(-90deg);
}

.sidebar-section-items.hidden {
    display: none;
}

.sidebar-item {
    padding: 10px 16px 10px 24px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background var(--transition-speed);
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background: var(--bg-hover);
}

.sidebar-item.active {
    background: var(--bg-active);
    color: var(--text-active);
    border-left: 3px solid var(--accent);
}

/* ── Sidebar overlay (mobile) ── */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

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

/* ── Content area ── */

.content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
}

#content-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .content {
        margin-left: 0;
    }
}

/* ── Login page ── */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.login-title {
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-active);
    text-align: center;
}

/* ── Forms ── */

.form-group {
    margin-bottom: 1rem;
}

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

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

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}

.form-group select option {
    background: var(--bg-input);
}

/* ── Buttons ── */

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-speed);
}

.btn-primary:hover {
    opacity: 0.85;
}

.btn-full {
    width: 100%;
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity var(--transition-speed);
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* ── Flash messages ── */

.flash {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.flash-success {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.flash-error {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid var(--error);
    color: var(--error);
}

.flash-info {
    background: rgba(33, 150, 243, 0.15);
    border: 1px solid #2196f3;
    color: #2196f3;
}

/* ── Admin Users page ── */

.admin-users-wrapper {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.admin-users-header {
    margin-bottom: 1.5rem;
}

.admin-users-header h1 {
    margin: 0.5rem 0 0 0;
    font-size: 1.5rem;
    color: var(--text-active);
}

.back-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Users table ── */

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.users-table th {
    text-align: left;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.users-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.users-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

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

.table-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* ── Role badges ── */

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
}

.role-manager {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
}

.role-viewer {
    background: rgba(160, 160, 160, 0.2);
    color: var(--text-secondary);
}

/* ── Create user form ── */

.create-user-form {
    max-width: 480px;
}
