/* ================================================
   Planum — Design System
   ================================================ */

:root {
    --primary: #2d1b4e;
    --primary-light: #3d2a5c;
    --secondary: #7c5caa;
    --secondary-light: #9b7ec8;
    --accent: #c9a84c;
    --accent-light: #e0c76e;
    --bg: #f5f3f8;
    --bg-alt: #f8f6fb;
    --bg-dark: #1a1030;
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-500: #71717a;
    --gray-600: #52525b;
    --gray-700: #3f3f46;
    --gray-800: #27272a;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --sidebar-width: 260px;
    --topbar-height: 60px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: 'Libre Baskerville', serif;
    color: var(--primary);
}

a { color: var(--secondary); text-decoration: none; }
a:hover { color: var(--primary); }

/* ================================================
   Layout
   ================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
}

.sidebar-logo-icon {
    width: 36px;
    height: auto;
}

.sidebar-logo-text {
    font-family: 'Libre Baskerville', serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-item.active {
    background: var(--secondary);
    color: var(--white);
}

.nav-item i { width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}

.nav-item-logout { color: rgba(255,255,255,0.5); font-size: 0.85rem; }
.nav-item-logout:hover { color: var(--error); }

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

.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-menu {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--gray-600);
    cursor: pointer;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--gray-800);
}

.content-area {
    padding: 24px;
    max-width: 1200px;
}

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

/* ================================================
   Components
   ================================================ */

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    font-family: 'Inter', sans-serif;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

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

.btn-accent {
    background: var(--accent);
    color: var(--primary);
}
.btn-accent:hover { background: var(--accent-light); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-600);
}
.btn-outline:hover { border-color: var(--secondary); color: var(--secondary); }

.btn-danger {
    background: var(--error);
    color: var(--white);
}
.btn-danger:hover { background: #dc2626; color: var(--white); }

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

/* Forms */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
    background: var(--white);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--secondary);
}

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

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* Table */
.table-wrap {
    overflow-x: auto;
}

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

thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

tbody td {
    padding: 12px 14px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover { background: var(--bg-alt); }

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

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-icon.purple { background: rgba(124,92,170,0.15); color: var(--secondary); }
.stat-icon.gold { background: rgba(201,168,76,0.15); color: var(--accent); }
.stat-icon.green { background: rgba(34,197,94,0.15); color: var(--success); }
.stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--info); }

.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--gray-500); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 1rem; margin-bottom: 20px; }

/* Badge */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-purple { background: rgba(124,92,170,0.15); color: var(--secondary); }
.badge-gold { background: rgba(201,168,76,0.15); color: #8b7028; }
.badge-green { background: rgba(34,197,94,0.15); color: #166534; }

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--secondary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 0.9rem;
}

/* Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--gray-500); }

/* ================================================
   Responsive (Mobile)
   ================================================ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close {
        display: block;
    }
    .sidebar-overlay.show {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .topbar-menu {
        display: block;
    }
    .content-area {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

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