@charset "UTF-8";

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --sidebar: #1e293b;
    --sidebar-hover: #334155;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Tahoma', 'Segoe UI', sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar);
    color: #fff;
    flex-shrink: 0;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 12px 20px 20px;
    font-size: 18px;
    font-weight: bold;
    border-bottom: 1px solid #334155;
    margin-bottom: 12px;
}

.sidebar a {
    display: block;
    padding: 10px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: background .15s;
    font-size: 14px;
}

.sidebar a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar a.active { background: var(--primary); color: #fff; }

.main {
    flex: 1;
    padding: 24px;
    overflow-x: auto;
}

.page-title {
    font-size: 22px;
    margin-bottom: 20px;
    font-weight: bold;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid var(--border);
}

.card .label { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: bold; }

.card.primary .value { color: var(--primary); }
.card.success .value { color: var(--success); }
.card.warning .value { color: var(--warning); }
.card.danger .value { color: var(--danger); }

.panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.panel h3 {
    font-size: 16px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s;
    text-decoration: none;
}

.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th, table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

table th {
    background: #f8fafc;
    font-weight: bold;
    color: var(--text-muted);
    font-size: 13px;
}

table tr:hover td { background: #f8fafc; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.badge-ok { background: #dcfce7; color: #166534; }
.badge-low { background: #fef3c7; color: #92400e; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: bold; font-size: 13px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 14px;
}

.alert-info { background: #dbeafe; color: #1e40af; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-danger { background: #fee2e2; color: #991b1b; }

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}

.toolbar input, .toolbar select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.toolbar .spacer { flex: 1; }

.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.qr-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    position: relative;
}

.qr-item img { width: 100%; max-width: 160px; height: auto; }
.qr-item .name { font-weight: bold; margin-top: 8px; font-size: 13px; }
.qr-item .code { color: var(--text-muted); font-size: 11px; direction: ltr; word-break: break-all; }
.qr-item input[type="checkbox"] {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 18px;
    height: 18px;
}

/* Scanner */
#scanner-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

#scanner-container video {
    width: 100%;
    display: block;
}

.scan-overlay {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(37,99,235,.5);
    pointer-events: none;
}

#scan-status {
    text-align: center;
    padding: 12px;
    font-weight: bold;
}

.scan-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(22,163,74,.95);
    color: #fff;
    padding: 24px 40px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    z-index: 9999;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
    animation: fadeInOut 1.8s ease-in-out;
}

.scan-toast.error { background: rgba(220,38,38,.95); }

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -60%); }
    15% { opacity: 1; transform: translate(-50%, -50%); }
    85% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -40%); }
}

/* Invoice */
.invoice-items table { font-size: 14px; }
.invoice-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--border);
    font-size: 18px;
}

.invoice-total .label { color: var(--text-muted); }
.invoice-total .amount { font-weight: bold; color: var(--success); font-size: 22px; }

.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.qty-control button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-weight: bold;
}

.qty-control button:hover { background: #f1f5f9; }
.qty-control .qty { min-width: 30px; text-align: center; font-weight: bold; }

/* Print invoice */
.invoice-print-area {
    background: #fff;
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
    border: 1px solid var(--border);
}

.invoice-print-area .invoice-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.invoice-print-area .store-name { font-size: 22px; font-weight: bold; }
.invoice-print-area .invoice-meta { margin-top: 10px; color: #555; }

.invoice-print-area table { margin-top: 20px; }
.invoice-print-area .total-row { font-weight: bold; font-size: 16px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}

.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Responsive */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        display: flex;
        overflow-x: auto;
        padding: 8px;
        white-space: nowrap;
    }
    .sidebar-brand { display: none; }
    .sidebar a { padding: 8px 14px; display: inline-block; font-size: 13px; }
    .main { padding: 14px; }
    .cards { grid-template-columns: repeat(2, 1fr); }
    .qr-grid { grid-template-columns: repeat(2, 1fr); }
    table { font-size: 13px; }
    table th, table td { padding: 8px; }
}

@media (max-width: 480px) {
    .cards { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* Print styles */
@media print {
    .sidebar, .toolbar, .no-print, .btn { display: none !important; }
    .main { padding: 0; }
    body { background: #fff; }
}

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.w-100 { width: 100%; }
.d-none { display: none !important; }