/* ============================================================
   Kitchen Hardware Shop Inventory Management System
   Custom Styles
   ============================================================ */

/* ===== CSS Variables ===== */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0ea5e9;
    --sidebar-text: #cbd5e1;
    --sidebar-heading: #94a3b8;
    --topbar-height: 60px;
    --footer-height: 50px;
    --primary-color: #0ea5e9;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1e293b;
    --light-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --card-hover-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

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

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

/* ===== Sidebar Styles ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-hover);
    border-radius: 4px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--sidebar-active);
}

.sidebar-brand:hover {
    color: var(--sidebar-active);
}

.sidebar-toggle-btn {
    padding: 2px 6px;
    font-size: 1.2rem;
}

.sidebar-divider {
    border-color: rgba(255,255,255,0.1);
    margin: 8px 16px;
}

.sidebar-user {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user img {
    border: 2px solid var(--sidebar-active);
}

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

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
}

.user-role {
    font-size: 0.75rem;
    margin-top: 2px;
}

/* Sidebar Navigation */
.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.nav-item {
    padding: 0;
}

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

.nav-link i:first-child {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

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

.nav-link.active {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
    border-left-color: var(--sidebar-active);
}

.nav-link.collapsed .bi-chevron-down {
    transform: rotate(0deg);
    transition: transform 0.2s;
}

.nav-link .bi-chevron-down {
    transform: rotate(-180deg);
    transition: transform 0.2s;
}

.nav-collapse {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.1);
}

.nav-link-sub {
    display: block;
    padding: 8px 20px 8px 55px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

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

.sidebar-footer {
    padding: 10px 0;
}

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

.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-user .user-info,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .bi-chevron-down,
.sidebar.collapsed .nav-collapse {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .nav-link i {
    margin: 0;
}

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

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Top Navbar ===== */
.navbar {
    height: var(--topbar-height);
    border-bottom: 1px solid #e2e8f0;
}

.navbar-brand {
    font-weight: 600;
    color: var(--dark-color) !important;
}

/* ===== Page Content ===== */
.page-content {
    flex: 1;
    padding: 20px;
    background-color: var(--light-bg);
}

/* ===== Footer ===== */
.footer {
    height: var(--footer-height);
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 0.85rem;
    color: var(--secondary-color);
}

/* ===== Cards ===== */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease;
    margin-bottom: 20px;
}

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

.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 15px 20px;
    font-weight: 600;
    border-radius: 10px 10px 0 0 !important;
}

.card-body {
    padding: 20px;
}

.card-footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 20px;
    border-radius: 0 0 10px 10px !important;
}

/* Stat Cards */
.stat-card {
    border-left: 4px solid;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
}

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

.stat-primary {
    border-left-color: var(--primary-color);
}
.stat-success {
    border-left-color: var(--success-color);
}
.stat-warning {
    border-left-color: var(--warning-color);
}
.stat-danger {
    border-left-color: var(--danger-color);
}
.stat-info {
    border-left-color: var(--info-color);
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary-color);
    border-top: none;
    white-space: nowrap;
}

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

.table-actions {
    white-space: nowrap;
}

.table-actions .btn {
    padding: 2px 8px;
    font-size: 0.8rem;
}

/* ===== DataTables Override ===== */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 8px;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

/* ===== Forms ===== */
.form-control, .form-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--dark-color);
    margin-bottom: 4px;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
}

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

.btn-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}

/* ===== Modals ===== */
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    border-bottom: 1px solid #e2e8f0;
    padding: 15px 20px;
}

.modal-footer {
    border-top: 1px solid #e2e8f0;
    padding: 12px 20px;
}

/* ===== Invoice Styles ===== */
.invoice-box {
    max-width: 800px;
    margin: auto;
    padding: 30px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    background: #fff;
}

.invoice-box table {
    width: 100%;
}

.invoice-box table td, .invoice-box table th {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0ea5e9 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary-color);
}

.login-logo h3 {
    margin-top: 10px;
    font-weight: 700;
}

/* ===== Product Image ===== */
.product-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.product-image-sm {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

/* ===== Notification Dropdown ===== */
.dropdown-notifications {
    max-height: 400px;
    overflow-y: auto;
}

/* ===== Select2 Override ===== */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
    border: 1px solid #d1d5db;
}

/* ===== Alert / Toast ===== */
.toast {
    min-width: 300px;
}

/* ===== Responsive Styles ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .brand-text,
    .sidebar-user .user-info,
    .nav-link span,
    .nav-link .bi-chevron-down,
    .nav-collapse {
        display: block !important;
    }
    
    .nav-link {
        justify-content: flex-start !important;
        padding: 12px 20px !important;
    }
}

@media (max-width: 767.98px) {
    .page-content {
        padding: 15px;
    }
    
    .stat-card {
        margin-bottom: 15px;
    }
    
    .login-card {
        margin: 20px;
        padding: 30px;
    }
}

/* ===== Print Styles ===== */
@media print {
    .sidebar, .navbar, .footer, .btn, .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .page-content {
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ===== Dashboard Specific ===== */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.activity-timeline {
    position: relative;
    padding-left: 30px;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.activity-item {
    position: relative;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 16px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
}

/* ===== Utility Classes ===== */
.cursor-pointer {
    cursor: pointer;
}

.text-primary-gradient {
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bg-soft-primary {
    background: rgba(14, 165, 233, 0.1);
}

.bg-soft-success {
    background: rgba(34, 197, 94, 0.1);
}

.bg-soft-warning {
    background: rgba(245, 158, 11, 0.1);
}

.bg-soft-danger {
    background: rgba(239, 68, 68, 0.1);
}

.bg-soft-info {
    background: rgba(59, 130, 246, 0.1);
}

/* ===== Image Preview ===== */
.image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    border: 2px dashed #d1d5db;
    padding: 5px;
}

/* ===== Barcode Styles ===== */
.barcode-wrapper {
    text-align: center;
    padding: 10px;
}

.barcode-wrapper svg {
    max-width: 100%;
    height: auto;
}
