/* ============================================================
   ERP2026 Application Styles
   ============================================================ */

/* ── Theme System ─────────────────────────────────────────── */
/* Applied via data-theme attribute on <html> element         */
/* Variables: primary, hover, muted, surface, header,        */
/*            accent (sidebar/focus), avatar-bg               */

:root,
[data-theme="blue"] {
    --theme-primary:         #1d4ed8;
    --theme-primary-hover:   #1e40af;
    --theme-primary-muted:   #93c5fd;
    --theme-primary-surface: #eff6ff;
    --theme-header:          #1e40af;
    --theme-accent:          #3b82f6;
    --theme-avatar-bg:       #2563eb;
    --theme-bg:              #f9fafb;  /* Tailwind gray-50 */
}

[data-theme="green"] {
    --theme-primary:         #16a34a;
    --theme-primary-hover:   #15803d;
    --theme-primary-muted:   #86efac;
    --theme-primary-surface: #f0fdf4;
    --theme-header:          #166534;
    --theme-accent:          #22c55e;
    --theme-avatar-bg:       #16a34a;
}

[data-theme="purple"] {
    --theme-primary:         #7c3aed;
    --theme-primary-hover:   #6d28d9;
    --theme-primary-muted:   #c4b5fd;
    --theme-primary-surface: #f5f3ff;
    --theme-header:          #5b21b6;
    --theme-accent:          #8b5cf6;
    --theme-avatar-bg:       #7c3aed;
}

[data-theme="rose"] {
    --theme-primary:         #e11d48;
    --theme-primary-hover:   #be185d;
    --theme-primary-muted:   #fda4af;
    --theme-primary-surface: #fff1f2;
    --theme-header:          #9f1239;
    --theme-accent:          #f43f5e;
    --theme-avatar-bg:       #e11d48;
}

[data-theme="amber"] {
    --theme-primary:         #d97706;
    --theme-primary-hover:   #b45309;
    --theme-primary-muted:   #fcd34d;
    --theme-primary-surface: #fffbeb;
    --theme-header:          #78350f;
    --theme-accent:          #f59e0b;
    --theme-avatar-bg:       #d97706;
}

[data-theme="slate"] {
    --theme-primary:         #475569;
    --theme-primary-hover:   #334155;
    --theme-primary-muted:   #94a3b8;
    --theme-primary-surface: #f8fafc;
    --theme-header:          #1e293b;
    --theme-accent:          #64748b;
    --theme-avatar-bg:       #475569;
}

/* Industrial Refined — dark steel header, amber/gold accents, warm off-white bg */
[data-theme="industrial"] {
    --theme-primary:         #D4860A;  /* amber gold (ProcureFlow --accent) */
    --theme-primary-hover:   #B8720A;  /* darker amber */
    --theme-primary-muted:   #F5C97A;  /* light amber */
    --theme-primary-surface: #FEF3E2;  /* warm amber tint */
    --theme-header:          #1C2128;  /* dark steel (ProcureFlow --sidebar) */
    --theme-accent:          #F5A623;  /* lighter amber (ProcureFlow --accent-lt) */
    --theme-avatar-bg:       #B8720A;  /* deep amber avatar */
    --theme-bg:              #F5F3EE;  /* warm off-white (ProcureFlow --bg) */
}

[x-cloak] { display: none !important; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner-ring {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast {
    pointer-events: all;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    animation: slideIn 0.25s ease;
    max-width: 380px;
    font-size: 14px;
    line-height: 1.4;
}

.toast-success { background: #f0fdf4; border: 1px solid #86efac; color: #15803d; }
.toast-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }
.toast-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.toast-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; }

.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-close {
    background: none; border: none; cursor: pointer;
    opacity: 0.5; font-size: 14px; flex-shrink: 0;
    padding: 0; line-height: 1;
}
.toast-close:hover { opacity: 1; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--theme-primary);
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    line-height: 1.25;
}
.btn-primary:hover { background: var(--theme-primary-hover); }
.btn-primary:disabled { background: var(--theme-primary-muted); cursor: not-allowed; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #f3f4f6;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    line-height: 1.25;
}
.btn-secondary:hover { background: #e5e7eb; }

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #ef4444;
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    color: var(--theme-primary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1.5px solid var(--theme-primary);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-outline:hover { background: var(--theme-primary-surface); }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* ── Form Inputs ─────────────────────────────────────────── */
.input-field {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    background: white;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
}
.input-field:focus {
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 3px var(--theme-primary-muted);
}
.input-field.error { border-color: #ef4444; }
.input-field:disabled { background: #f9fafb; color: #9ca3af; }

select.input-field { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 10px center; background-repeat: no-repeat; background-size: 16px; padding-right: 32px; appearance: none; }

textarea.input-field { resize: vertical; min-height: 80px; }

.label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 5px; }
.label.required::after { content: ' *'; color: #ef4444; }

/* ── Tables ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: #f8fafc;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.data-table td {
    padding: 11px 14px;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

.card-header h2, .card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13.5px;
    color: #9ca3af;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.12s;
    font-weight: 400;
}
.sidebar-link:hover {
    color: white;
    background: rgba(255,255,255,0.05);
    border-left-color: var(--theme-accent);
}
.sidebar-link.active {
    color: white;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--theme-accent);
    font-weight: 500;
}
.sidebar-section {
    padding: 12px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #4b5563;
    text-transform: uppercase;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-box {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

.modal-sm { max-width: 400px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.modal-title { font-size: 17px; font-weight: 600; color: #111827; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: #9ca3af; font-size: 18px; padding: 4px;
    border-radius: 6px; line-height: 1;
}
.modal-close:hover { color: #374151; background: #f3f4f6; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f3f4f6; color: #4b5563; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    gap: 0;
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    white-space: nowrap;
}
.tab-btn.active { color: var(--theme-primary); border-bottom-color: var(--theme-primary); }
.tab-btn:hover:not(.active) { color: #374151; background: #f9fafb; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 6px; font-size: 13px;
    color: #374151; border: 1px solid #e5e7eb; cursor: pointer;
    text-decoration: none; transition: all 0.12s; background: white;
}
.page-btn:hover { background: #f3f4f6; border-color: #d1d5db; }
.page-btn.active { background: var(--theme-primary); color: white; border-color: var(--theme-primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Priority color dot ──────────────────────────────────── */
.priority-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Color picker preview ────────────────────────────────── */
.color-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    flex-shrink: 0;
}

/* ── Status chips (PO/WO) ────────────────────────────────── */
.status-editing        { @apply badge badge-gray; }
.status-pending_approval { background: #fef9c3; color: #854d0e; }
.status-ordered        { background: #dbeafe; color: #1e40af; }
.status-received       { background: #dcfce7; color: #15803d; }
.status-rejected       { background: #fee2e2; color: #b91c1c; }
.status-pending        { background: #f3f4f6; color: #4b5563; }
.status-started        { background: #dbeafe; color: #1e40af; }
.status-closed         { background: #dcfce7; color: #15803d; }

/* ── Print styles ────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    .card { box-shadow: none; border: 1px solid #e5e7eb; }
}

/* ── Responsive table wrapper ────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 10px; }

/* ── Form grid helpers ───────────────────────────────────── */
.form-row { display: grid; gap: 14px; margin-bottom: 14px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

@media (max-width: 640px) {
    .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}
