/* === Global Styles === */
:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #3B82F6;
    --secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #06B6D4;
    --bg-light: #F8FAFC;
    --bg-white: #FFFFFF;
    --text-dark: #1E293B;
    --text-gray: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
    --radius-sm: 0.5rem;
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
    z-index: 40;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

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

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.sidebar-title { color: white; font-weight: 600; font-size: 0.95rem; line-height: 1.2; }
.sidebar-subtitle { color: #94A3B8; font-size: 0.7rem; }

.sidebar-nav { padding: 1rem 0; }

.sidebar-section {
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
}

.sidebar-section-title {
    color: #64748B;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #94A3B8;
    text-decoration: none;
    border-radius: 0.5rem;
    margin: 0.125rem 0.5rem;
    transition: var(--transition);
    font-size: 0.875rem;
    position: relative;
}

.sidebar-link:hover { color: white; background: rgba(255,255,255,0.08); }
.sidebar-link.active { color: white; background: var(--primary); }
.sidebar-link i { font-size: 1.1rem; width: 1.5rem; text-align: center; }

.sidebar-badge {
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: auto;
}

/* === Header === */
.header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.header-left { display: flex; align-items: center; gap: 1rem; }

.hamburger-btn {
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: var(--transition);
    display: none;
}

.hamburger-btn:hover { background: var(--bg-light); }

.header-search {
    position: relative;
    max-width: 400px;
}

.header-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg-light);
    font-size: 0.875rem;
    transition: var(--transition);
}

.header-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.header-search i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--text-light); }

.header-right { display: flex; align-items: center; gap: 0.5rem; }

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    border: none;
    background: none;
    color: var(--text-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
    font-size: 1.2rem;
}

.header-btn:hover { background: var(--bg-light); color: var(--text-dark); }

.header-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 0.75rem;
    object-fit: cover;
    cursor: pointer;
}

/* === Main Content === */
.main-content {
    margin-left: 260px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

.main-content.expanded { margin-left: 0; }

.page-content { padding: 1.5rem; }

/* === Page Title === */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle { color: var(--text-gray); font-size: 0.875rem; margin-bottom: 1.5rem; }

/* === Cards === */
.card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title { font-weight: 600; font-size: 1rem; }
.card-body { padding: 1.5rem; }

/* === Stat Cards === */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: var(--text-gray); font-size: 0.8rem; margin-top: 0.25rem; }
.stat-card .stat-change { font-size: 0.75rem; margin-top: 0.5rem; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-dark); }
.btn-outline:hover { background: var(--bg-light); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; color: var(--text-dark); }
.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: var(--transition);
    background: white;
}

.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control:disabled { background: var(--bg-light); cursor: not-allowed; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.5rem; }

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

/* === Tables === */
.table-container { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

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

table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-gray);
    background: var(--bg-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tbody tr:hover { background: #F8FAFC; }
table tbody tr:last-child td { border-bottom: none; }

/* === Grid === */
.grid { display: grid; gap: 1.5rem; }
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 400px; }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 1;
}

.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* === Off Canvas === */
.off-canvas {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    background: white;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-xl);
}

.off-canvas.open { transform: translateX(0); }

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

.off-canvas-overlay.open { display: block; }

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: none;
    z-index: 40;
    padding: 0.5rem;
    justify-content: space-around;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--text-gray);
    font-size: 0.65rem;
    text-decoration: none;
    transition: var(--transition);
    border-radius: 0.5rem;
}

.bottom-nav-item i { font-size: 1.25rem; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { color: var(--primary); }

/* === FAB === */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 12px rgba(37,99,235,0.4);
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.fab:hover { background: var(--primary-dark); transform: scale(1.05); box-shadow: 0 6px 16px rgba(37,99,235,0.5); }

/* === Animations === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-slideUp { animation: slideUp 0.3s ease; }

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === Glassmorphism === */
.glass {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
}

/* === Dark Mode === */
.dark { --bg-light: #0F172A; --bg-white: #1E293B; --text-dark: #F1F5F9; --text-gray: #94A3B8; --text-light: #64748B; --border: #334155; }
.dark body { background: var(--bg-light); color: var(--text-dark); }
.dark .card, .dark .stat-card, .dark table { background: var(--bg-white); }
.dark table th { background: #1E293B; }
.dark table tbody tr:hover { background: #334155; }
.dark .form-control { background: #1E293B; color: var(--text-dark); border-color: var(--border); }
.dark .header { background: rgba(15,23,42,0.8); }
.dark .modal { background: var(--bg-white); }
.dark .modal-header { background: var(--bg-white); }
.dark .bottom-nav { background: rgba(15,23,42,0.95); }
.dark .off-canvas { background: var(--bg-white); }

/* === Responsive === */
@media (max-width: 1199px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger-btn { display: block; }
    .grid-cols-6 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 991px) {
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-2 { grid-template-columns: 1fr; }
    .header-search { max-width: 200px; }
}

@media (max-width: 767px) {
    .sidebar { display: none; }
    .bottom-nav { display: flex; }
    .page-content { padding: 1rem; padding-bottom: 5rem; }
    .grid-cols-6, .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
    .header-search { display: none; }
    .header { padding: 0 1rem; }
    .fab { bottom: 5rem; }
    .page-title { font-size: 1.25rem; }

    table thead { display: none; }
    table tbody tr { display: block; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
    table tbody td { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
    table tbody td:last-child { border-bottom: none; }
    table tbody td::before { content: attr(data-label); font-weight: 600; color: var(--text-gray); font-size: 0.7rem; text-transform: uppercase; }
    .table-container { border: none; }
}

@media (max-width: 480px) {
    .header { height: 56px; }
    .card-header { padding: 1rem; }
    .card-body { padding: 1rem; }
    .stat-card { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .btn { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
}

/* === Print === */
@media print {
    .sidebar, .header, .bottom-nav, .fab, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}