/* XCRETCH ERP - Main Stylesheet */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 52px;
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --dark-sidebar: #111827;
    --dark-sidebar-hover: #1f2937;
    --dark-sidebar-active: #4f46e5;
    --body-bg: #f3f4f6;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13.5px;
    background: var(--body-bg);
    color: #1f2937;
    margin: 0;
}

#app { min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    background: var(--dark-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.25s ease;
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
}

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

.sidebar-brand {
    min-height: 52px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-nav {
    padding-bottom: 2rem;
    overflow-y: auto;
    flex: 1;
}

.sidebar-section small {
    display: block;
    padding: 8px 12px 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #6b7280;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    color: #9ca3af;
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    line-height: 1.4;
}
.sidebar-link:hover {
    color: #f3f4f6;
    background: var(--dark-sidebar-hover);
}
.sidebar-link.active {
    color: #fff;
    background: var(--dark-sidebar-active);
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}
.sidebar-link i {
    width: 20px;
    margin-right: 10px;
    font-size: 15px;
    opacity: 0.85;
}
.sidebar-link.active i { opacity: 1; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.25s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1030;
    background: #fff;
    border-bottom: 1px solid #e5e7eb !important;
}

.content-wrapper {
    flex: 1;
    padding: 1.25rem !important;
    background: var(--body-bg);
}

/* Collapsed sidebar */
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }
.sidebar.collapsed + .main-content,
body.sidebar-collapsed .main-content { margin-left: 0; }

/* Cards */
.card {
    border: 1px solid #e5e7eb !important;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}
.card-header {
    border-radius: 10px 10px 0 0 !important;
    background: #fff !important;
    border-bottom: 1px solid #e5e7eb !important;
}

/* Tables */
.table {
    margin-bottom: 0;
}
.table th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    border-bottom-width: 1px;
    padding: 10px 12px;
}
.table td {
    vertical-align: middle;
    font-size: 13px;
    padding: 10px 12px;
    border-color: #f3f4f6;
}
.table-hover tbody tr:hover { background-color: #f9fafb; }

/* Status Badges */
.badge-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

/* Forms */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}
.form-label {
    font-weight: 500;
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toast */
.toast-container { z-index: 9999; }

/* Empty state */
.empty-state {
    padding: 3rem;
    text-align: center;
    color: #9ca3af;
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* KPI Cards */
.kpi-card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.15s ease;
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page header */
.page-header {
    margin-bottom: 1.25rem;
}
.page-header h4 {
    font-weight: 700;
    color: #111827;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1035;
    }
    .sidebar.show ~ .sidebar-overlay { display: block; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 1rem !important; }
}

/* Print */
@media print {
    .sidebar, .top-bar, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 0 !important; background: #fff !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* Mobile sidebar hint */
@media (max-width: 768px) {
    #sidebarToggle {
        font-size: 1.2rem;
        padding: 4px 8px;
        border-width: 2px;
    }
}
