/* ============================================
   GhosTech Mechanic Shop - Custom Styles
   ============================================ */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;
    --topbar-height: 56px;
    --primary-color: #2563eb;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --content-bg: #f1f5f9;
}

/* ---- Global ---- */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--content-bg);
    overflow-x: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1040;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: var(--topbar-height);
}

.sidebar-header i {
    color: var(--primary-color);
    font-size: 1.4rem;
}

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav li.active a {
    background: rgba(37, 99, 235, 0.15);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active);
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    margin-right: 12px;
    font-size: 0.95rem;
}

.sidebar-nav .nav-section {
    padding: 18px 20px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* ---- Main Content ---- */
#main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar .sidebar-toggle {
    color: #475569;
    font-size: 1.2rem;
    padding: 4px 8px;
}

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

.topbar-right .btn-link {
    color: #475569;
    text-decoration: none;
}

.content-wrapper {
    padding: 24px;
}

/* ---- Sidebar Collapsed ---- */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar .sidebar-brand,
body.sidebar-collapsed .sidebar .sidebar-nav li a span,
body.sidebar-collapsed .sidebar .nav-section {
    display: none;
}

body.sidebar-collapsed .sidebar .sidebar-nav li a {
    justify-content: center;
    padding: 12px 0;
    border-left: none;
}

body.sidebar-collapsed .sidebar .sidebar-nav li a i {
    margin: 0;
    font-size: 1.1rem;
}

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

/* ---- Cards ---- */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transform: translateY(-1px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Content Cards ---- */
.content-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.content-card .card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-card .card-header h5 {
    margin: 0;
    font-weight: 600;
    color: #1e293b;
    font-size: 1rem;
}

.content-card .card-body {
    padding: 20px;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

/* ---- Tables ---- */
.table th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ---- Forms ---- */
.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #475569;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* ---- Modals ---- */
.modal-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.modal-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* ---- Low Stock Alert ---- */
.low-stock {
    color: #dc2626;
    font-weight: 600;
}

.stock-ok {
    color: #16a34a;
}

/* ---- Quick Actions ---- */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.quick-action:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.quick-action i {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.quick-action span {
    font-size: 0.82rem;
    font-weight: 500;
}

/* ---- Select2 Tweaks ---- */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
}

/* ---- Print Styles ---- */
@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }
    #main-content {
        margin-left: 0 !important;
    }
    .content-wrapper {
        padding: 0 !important;
    }
}

/* ---- Responsive ---- */

/* Mobile overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1035;
}

body.sidebar-open .sidebar-overlay {
    display: block;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    
    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }
    
    #main-content {
        margin-left: 0;
    }
    
    body.sidebar-collapsed #main-content {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 16px 12px;
    }
    
    /* Topbar mobile */
    .topbar {
        padding: 0 12px;
    }
    
    .topbar-right {
        gap: 4px;
    }
    
    .topbar-right .btn-sm {
        padding: 4px 8px;
        font-size: .75rem;
    }
    
    .topbar-right .dropdown .btn-link {
        font-size: .85rem;
        padding: 4px 6px;
    }
    
    .topbar-right .dropdown .btn-link small {
        display: none;
    }
    
    /* Page header stacks vertically */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 14px;
    }
    
    .stat-card .stat-value {
        font-size: 1.3rem;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.72rem;
    }
    
    /* Quick actions */
    .quick-action {
        padding: 14px 10px;
    }
    
    .quick-action i {
        font-size: 1.2rem;
        margin-bottom: 6px;
    }
    
    .quick-action span {
        font-size: 0.75rem;
    }
    
    /* Tables */
    .table-responsive {
        margin: 0 -1px;
    }
    
    .table th, .table td {
        white-space: nowrap;
        font-size: 0.82rem;
        padding: 8px 10px;
    }
    
    .table th {
        font-size: 0.7rem;
    }
    
    /* Content cards */
    .content-card .card-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .content-card .card-header h5 {
        font-size: 0.9rem;
    }
    
    .content-card .card-body {
        padding: 14px;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 8px;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 0.9rem;
    }
    
    /* Buttons inline groups */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
    
    .d-flex.gap-2 .btn {
        font-size: 0.82rem;
    }
    
    /* DataTables mobile */
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter {
        text-align: left !important;
        margin-bottom: 8px;
    }
    
    div.dataTables_wrapper div.dataTables_filter input {
        width: 100% !important;
        max-width: 100%;
    }
    
    div.dataTables_wrapper div.dataTables_info {
        font-size: .75rem;
        padding-top: 8px;
    }
    
    div.dataTables_wrapper div.dataTables_paginate ul.pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Alerts */
    .alert {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
    
    /* Badge smaller */
    .badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
}

/* Extra small screens */
@media (max-width: 575px) {
    .content-wrapper {
        padding: 12px 8px;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.1rem;
    }
    
    .topbar-right .lang-label {
        display: none;
    }
    
    /* Stack page header actions */
    .page-header .btn {
        font-size: .8rem;
        padding: 6px 10px;
    }

    /* Compact tables */
    .table th, .table td {
        padding: 6px 8px;
        font-size: 0.78rem;
    }
}

/* ---- DataTables overrides ---- */
div.dataTables_wrapper div.dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
}

div.dataTables_wrapper div.dataTables_length select {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* ---- Loading spinner ---- */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ---- Rental Truck Card ---- */
.truck-card {
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.truck-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
}

.truck-card .truck-img {
    height: 160px;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 3rem;
}

/* ---- Color utilities ---- */
.bg-blue-light { background: rgba(37,99,235,.1); color: #2563eb; }
.bg-green-light { background: rgba(22,163,74,.1); color: #16a34a; }
.bg-orange-light { background: rgba(234,88,12,.1); color: #ea580c; }
.bg-red-light { background: rgba(220,38,38,.1); color: #dc2626; }
.bg-purple-light { background: rgba(147,51,234,.1); color: #9333ea; }
.bg-teal-light { background: rgba(13,148,136,.1); color: #0d9488; }
