/* ====================================================
   Global Reset & Variables
   ==================================================== */
:root {
    --primary: #1e293b;
    --primary-light: #334155;
    --primary-dark: #0f172a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --success-hover: #16a34a;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ====================================================
   Layout
   ==================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--primary-dark);
    color: #fff;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}
.sidebar .logo {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    letter-spacing: -0.5px;
}
.sidebar nav ul {
    list-style: none;
}
.sidebar nav ul li {
    margin-bottom: 0.25rem;
}
.sidebar nav ul li a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: #cbd5e1;
    transition: background 0.15s, color 0.15s;
}
.sidebar nav ul li a:hover,
.sidebar nav ul li a.active {
    background: var(--primary-light);
    color: #fff;
    text-decoration: none;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    max-width: 100%;
}

/* ====================================================
   Login Page
   ==================================================== */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--surface);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.login-container h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* ====================================================
   Forms
   ==================================================== */
form {
    max-width: 100%;
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

/* ====================================================
   Form Inputs - Full Styling for All Types
   ==================================================== */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Date input - custom styling */
.form-group input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    min-height: 44px;
    cursor: pointer;
}
.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    padding: 0.25rem;
    cursor: pointer;
}

/* File input - custom styling */
.form-group input[type="file"] {
    padding: 0.5rem;
    border: 2px dashed var(--border);
    background: var(--bg);
    cursor: pointer;
}
.form-group input[type="file"]:hover {
    border-color: var(--accent);
    background: #f8fafc;
}
.form-group input[type="file"]::-webkit-file-upload-button {
    padding: 0.4rem 1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-weight: 500;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: background 0.2s;
}
.form-group input[type="file"]::-webkit-file-upload-button:hover {
    background: var(--accent-hover);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}
.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Form row grid (for multi-column forms) */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-row .form-group {
    margin-bottom: 0;
}

/* Form actions */
.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ====================================================
   Image Preview
   ==================================================== */
#imagePreview {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    display: none;
}
#imagePreview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 4px;
    border: 2px solid var(--border);
    object-fit: cover;
}

/* ====================================================
   Barcode Scanner Modal
   ==================================================== */
#barcodeScannerModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    padding: 2rem;
    justify-content: center;
    align-items: center;
}
#barcodeScannerModal .modal-content {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    box-shadow: var(--shadow-lg);
}
#barcodeScannerModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
#barcodeScannerModal .modal-header h3 {
    margin: 0;
}
#barcodeScannerModal .close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.2s;
}
#barcodeScannerModal .close-btn:hover {
    color: var(--text);
}
#scannerContainer {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    min-height: 250px;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}
#barcodeScannerModal .modal-footer {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ====================================================
   Quick Add Modal
   ==================================================== */
#quickAddModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    padding: 2rem;
    align-items: center;
    justify-content: center;
}
#quickAddModal .modal-content {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}
#quickAddModal .modal-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}
#quickAddModal .modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
#quickAddModal .modal-actions button {
    flex: 1;
}

/* ====================================================
   Product Images Gallery (Edit page)
   ==================================================== */
.product-images-gallery {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.product-images-gallery .image-item {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}
.product-images-gallery .image-item:hover {
    transform: scale(1.02);
}
.product-images-gallery .image-item img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
}
.product-images-gallery .image-item .primary-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent);
    color: #fff;
    padding: 0.1rem 0.5rem;
    font-size: 0.6rem;
    border-radius: 0 var(--radius) 0 var(--radius);
    font-weight: 500;
    text-transform: uppercase;
}
.product-images-gallery .image-item .actions {
    margin-top: 0.5rem;
    text-align: center;
}

/* ====================================================
   Buttons
   ==================================================== */
.btn,
button[type="submit"],
button[type="button"] {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    line-height: 1.5;
}
.btn:hover,
button:hover {
    background: var(--accent-hover);
    text-decoration: none;
}
.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--primary-light);
}
.btn-secondary:hover {
    background: var(--primary);
}

.btn-danger {
    background: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-success {
    background: var(--success);
}
.btn-success:hover {
    background: var(--success-hover);
}

.btn-warning {
    background: var(--warning);
}
.btn-warning:hover {
    background: var(--warning-hover);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
}
.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
}

/* ====================================================
   Alerts & Messages
   ==================================================== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}
.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.alert ul {
    margin: 0.25rem 0 0 1.5rem;
}

/* ====================================================
   Tables
   ==================================================== */
.table-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
table {
    width: 100%;
    border-collapse: collapse;
}
table th,
table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
table tr:last-child td {
    border-bottom: none;
}
table tbody tr:hover {
    background: #f8fafc;
}
table td .btn {
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* ====================================================
   Badges / Tags
   ==================================================== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.badge-success {
    background: #dcfce7;
    color: #166534;
}
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}
.badge-info {
    background: #dbeafe;
    color: #1e40af;
}
.badge-secondary {
    background: #e2e8f0;
    color: #475569;
}

/* ====================================================
   Info Box (for stock display, etc.)
   ==================================================== */
.info-box {
    background: var(--bg);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--accent);
}
.info-box strong {
    display: inline-block;
    min-width: 120px;
}

/* ====================================================
   Actions Bar (search + actions)
   ==================================================== */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.actions-bar .search-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
}
.actions-bar .search-form input[type="text"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    min-width: 200px;
    flex: 1;
}
.actions-bar .search-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.actions-bar .search-form select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
}
.actions-bar .search-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.actions-bar .search-form button {
    padding: 0.5rem 1.2rem;
}

/* ====================================================
   Dividers
   ==================================================== */
hr {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* ====================================================
   Typography & Utilities
   ==================================================== */
h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: -0.5px;
}
h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.text-muted {
    color: var(--text-muted);
}
.text-center {
    text-align: center;
}
.mb-2 {
    margin-bottom: 0.5rem;
}
.mb-3 {
    margin-bottom: 1rem;
}
.mb-4 {
    margin-bottom: 2rem;
}
.mt-2 {
    margin-top: 0.5rem;
}
.mt-3 {
    margin-top: 1rem;
}
.mt-4 {
    margin-top: 2rem;
}
.p-2 {
    padding: 0.5rem;
}
.p-3 {
    padding: 1rem;
}
.p-4 {
    padding: 2rem;
}

/* ====================================================
   Responsive
   ==================================================== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1rem;
    }
    .main-content {
        padding: 1rem;
    }
    .login-container {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }
    .form-actions {
        flex-wrap: wrap;
    }
    .form-actions .btn {
        width: 100%;
        text-align: center;
    }
    table th,
    table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .actions-bar .search-form {
        flex-direction: column;
    }
    .actions-bar .search-form input[type="text"] {
        min-width: unset;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-row .form-group {
        margin-bottom: 1.25rem;
    }
    .info-box strong {
        min-width: unset;
        display: block;
    }
    #barcodeScannerModal {
        padding: 1rem;
    }
    #barcodeScannerModal .modal-content {
        padding: 1rem;
    }
    #scannerContainer {
        min-height: 200px;
    }
    .product-images-gallery .image-item img {
        width: 80px;
        height: 80px;
    }
}