/* ============================================
   GMS - Gryb Management System
   Modern Dashboard Template
   ============================================ */

:root {
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-active: #6366f1;
    --sidebar-border: rgba(148, 163, 184, 0.08);

    /* Main */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Text */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Brand */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);

    /* Misc */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; border: none; background: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, h5, h6 { margin: 0; }

/* ============================================
   APP SHELL — Full screen layout
   ============================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: width var(--transition), min-width var(--transition);
    overflow: hidden;
}

/* Collapsed state */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    min-width: 0;
}

.brand-logo-wrap {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: #fff;
}

.brand-logo-fallback {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
}

.brand-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}

.brand-text h1 {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
}

.brand-text p {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--sidebar-text);
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Collapsed: hide text, center icons */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 8px 16px;
}
.sidebar.collapsed .sidebar-collapse-btn {
    display: none;
}
.sidebar.collapsed .brand {
    justify-content: center;
}
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px;
}
.sidebar.collapsed .nav-link i {
    margin: 0;
}
.sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 12px 8px;
}
.sidebar.collapsed .icon-btn-ghost {
    display: none;
}
.sidebar.collapsed .nav-group {
    padding: 0 8px;
}

/* Sidebar nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-group {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 600;
    padding: 16px 12px 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.nav-link i {
    font-size: 18px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text-hover);
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 12px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}
.sidebar-user-info strong {
    display: block;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}
.sidebar-user-info span {
    color: var(--sidebar-text);
    font-size: 11px;
}

.icon-btn-ghost {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.icon-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-wrap {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

body.sidebar-collapsed .main-wrap {
    margin-left: var(--sidebar-collapsed);
}

.main-content {
    flex: 1;
    padding: 0 32px 32px;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 32px;
    background: transparent;
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(241, 245, 249, 0.85);
}

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

.topbar-left #sidebarToggle {
    display: none;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.breadcrumb-item { color: var(--text-muted); }
.breadcrumb-item.current { color: var(--text); font-weight: 600; }
.breadcrumb-sep { font-size: 12px; color: var(--text-muted); }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0 14px;
    min-width: 240px;
    transition: var(--transition);
}
.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.search-box i {
    color: var(--text-muted);
    font-size: 16px;
}
.search-box input {
    width: 100%;
    padding: 9px 0;
    outline: none;
    color: var(--text);
    font-size: 13px;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
}
.icon-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}
.notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid var(--surface);
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    margin-bottom: 28px;
}
.page-header h2 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}
.page-header p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
}

/* ============================================
   MODULE CARDS (Home page)
   ============================================ */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--module-color, var(--primary));
    opacity: 0;
    transition: var(--transition);
}
.module-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.module-card:hover::before {
    opacity: 1;
}
.module-card.disabled {
    opacity: 0.55;
    cursor: default;
}
.module-card.disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
}

.module-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    font-size: 22px;
    color: #fff;
}

.module-card h3 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.module-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    flex: 1;
}

.module-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}
.module-badge.active {
    color: #10b981;
}
.module-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================
   METRIC CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
}
.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.stat-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}
.stat-change {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #10b981;
}
.stat-change.negative {
    color: #ef4444;
}

/* ============================================
   PANELS
   ============================================ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 16px;
    margin-bottom: 20px;
}
.panel-header h3 {
    font-size: 16px;
    font-weight: 700;
}
.panel-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

/* ============================================
   TABS
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 3px;
}
.tab {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.tab:hover {
    color: var(--text);
}
.tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    min-height: 300px;
    display: grid;
    place-items: center;
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    color: var(--text-muted);
    padding: 40px;
    background: var(--surface);
}
.empty-state i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 16px;
    display: block;
}
.empty-state h4 {
    color: var(--text);
    font-size: 18px;
    margin: 0 0 8px;
    font-weight: 700;
}
.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
}

/* ============================================
   TABLE
   ============================================ */
.table-clean {
    width: 100%;
    border-collapse: collapse;
}
.table-clean th,
.table-clean td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table-clean th {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.table-clean tr:last-child td {
    border-bottom: none;
}

/* ============================================
   CHIP / BADGE
   ============================================ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}
.chip-success {
    background: #ecfdf5;
    color: #059669;
}
.chip-warning {
    background: #fffbeb;
    color: #d97706;
}
.chip-danger {
    background: #fef2f2;
    color: #dc2626;
}
.chip-info {
    background: #eff6ff;
    color: #2563eb;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    .content-grid {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: 0 20px 20px;
    }
    .topbar {
        padding: 12px 20px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-wrap {
        margin-left: 0 !important;
    }
    .topbar-left #sidebarToggle {
        display: inline-grid;
    }
    .search-box {
        min-width: 160px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .modules-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   SCROLLBAR (global)
   ============================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   OVERLAY for mobile sidebar
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-overlay {
    display: block;
}
