/* ==========================================================================
   Infinity Plus Warehouse - Design System
   Brand Palette: Deep Petrol Navy (#0E4D64) and Vibrant Burnt Orange (#E85D1A)
   Clean, fast, mobile-first, accessible, zero emojis
   ========================================================================== */

:root {
    --brand-navy-950: #072633;
    --brand-navy-900: #0B394B;
    --brand-navy-800: #0E4D64;
    --brand-navy-700: #146380;
    --brand-navy-600: #1D7C9E;
    --brand-navy-100: #E7F3F7;
    --brand-navy-50: #F2F9FB;

    --brand-orange-700: #B8420C;
    --brand-orange-600: #D14E12;
    --brand-orange-500: #E85D1A;
    --brand-orange-400: #F47A3E;
    --brand-orange-100: #FFF1E9;
    --brand-orange-50: #FFF8F4;

    --surface-bg: #F3F6FA;
    --surface-card: #FFFFFF;
    --surface-subtle: #F8FAFC;
    --surface-hover: #F1F5F9;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --text-on-dark: #F8FAFC;

    --border-light: #E2E8F0;
    --border-strong: #CBD5E1;

    --status-success: #0F9D58;
    --status-success-bg: #E8F8F0;
    --status-warning: #D97706;
    --status-warning-bg: #FEF3C7;
    --status-danger: #DC2626;
    --status-danger-bg: #FEE2E2;
    --status-info: #0284C7;
    --status-info-bg: #E0F2FE;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(11, 57, 75, 0.05);
    --shadow-sm: 0 4px 12px rgba(11, 57, 75, 0.06);
    --shadow-md: 0 10px 26px rgba(11, 57, 75, 0.09);
    --shadow-lg: 0 22px 48px rgba(7, 38, 51, 0.18);
    --shadow-orange: 0 8px 20px rgba(232, 93, 26, 0.28);
    --shadow-navy: 0 8px 20px rgba(14, 77, 100, 0.26);

    --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
    --header-height: 68px;
    --sidebar-width: 276px;
    --mobile-nav-height: 68px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--surface-bg);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: 0.95rem;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(14, 77, 100, 0.22);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 77, 100, 0.4);
}

/* Smooth Keyframe Animations */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes spinIcon {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulseDot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.35);
        opacity: 0.55;
    }
}

.is-spinning i,
.is-spinning svg {
    animation: spinIcon 0.75s linear infinite;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.92rem;
    transition: transform 0.18s var(--ease-spring), box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-navy-800), var(--brand-navy-900));
    color: var(--text-on-dark);
    box-shadow: var(--shadow-navy);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--brand-navy-700), var(--brand-navy-800));
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--brand-orange-500), var(--brand-orange-600));
    color: #FFFFFF;
    box-shadow: var(--shadow-orange);
}

.btn-accent:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--brand-orange-400), var(--brand-orange-500));
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--surface-card);
    color: var(--brand-navy-800);
    border: 1.5px solid var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--brand-navy-800);
    background: var(--brand-navy-50);
}

.btn-soft {
    background: var(--brand-navy-100);
    color: var(--brand-navy-900);
}

.btn-soft:hover:not(:disabled) {
    background: #D6EAF0;
}

.btn-soft-orange {
    background: var(--brand-orange-100);
    color: var(--brand-orange-700);
}

.btn-soft-orange:hover:not(:disabled) {
    background: #FFE2D2;
}

.btn-success {
    background: var(--status-success);
    color: #FFFFFF;
}

.btn-success:hover:not(:disabled) {
    background: #0D8A4D;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--status-danger);
    color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
    background: #B91C1C;
}

.btn-soft-danger {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

.btn-soft-danger:hover:not(:disabled) {
    background: #FECACA;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.84rem;
    border-radius: 9px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
}

/* Inputs & Form Controls */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-label i {
    color: var(--brand-orange-500);
    font-size: 0.85rem;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-light);
    background: var(--surface-card);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--brand-navy-700);
    box-shadow: 0 0 0 3.5px rgba(14, 77, 100, 0.12);
}

.textarea {
    resize: vertical;
    min-height: 82px;
}

/* Cards */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.12rem;
    font-weight: 800;
    color: var(--brand-navy-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-navy-100);
    color: var(--brand-navy-800);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.card-title-icon.orange {
    background: var(--brand-orange-100);
    color: var(--brand-orange-600);
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.badge-pending {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

.badge-preparing {
    background: var(--status-warning-bg);
    color: var(--status-warning);
}

.badge-dispatched {
    background: var(--status-info-bg);
    color: var(--status-info);
}

.badge-unavailable {
    background: #F1F5F9;
    color: #475569;
}

.badge-fulfilled {
    background: var(--status-success-bg);
    color: var(--status-success);
}

.badge-branch {
    background: var(--brand-navy-100);
    color: var(--brand-navy-900);
    border: 1px solid rgba(14, 77, 100, 0.14);
}

/* Custom Toast Container (Zero Chrome Native Popups) */
.toast-stack {
    position: fixed;
    top: 82px;
    left: 20px;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-card);
    border: 1px solid var(--border-light);
    border-right: 4px solid var(--brand-navy-800);
    box-shadow: var(--shadow-lg);
    animation: fadeSlideUp 0.28s var(--ease-spring);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.toast-item.toast-success {
    border-right-color: var(--status-success);
}

.toast-item.toast-warning {
    border-right-color: var(--brand-orange-500);
}

.toast-item.toast-error {
    border-right-color: var(--status-danger);
}

.toast-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.toast-success .toast-icon {
    background: var(--status-success-bg);
    color: var(--status-success);
}

.toast-warning .toast-icon {
    background: var(--brand-orange-100);
    color: var(--brand-orange-600);
}

.toast-error .toast-icon {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

.toast-info .toast-icon {
    background: var(--brand-navy-100);
    color: var(--brand-navy-800);
}

.toast-close {
    margin-right: auto;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 6px;
}

.toast-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Custom Modals (Replaces Chrome alert, confirm, prompt) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(7, 38, 51, 0.56);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal-backdrop.is-open {
    display: flex;
}

.modal-dialog {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(14, 77, 100, 0.14);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    animation: modalPop 0.26s var(--ease-spring);
}

.modal-dialog.modal-lg {
    max-width: 720px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--brand-navy-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-subtle);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.modal-close-btn:hover {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
}

/* Dialog Icon Hero */
.dialog-hero-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.dialog-hero-icon.navy {
    background: var(--brand-navy-100);
    color: var(--brand-navy-800);
}

.dialog-hero-icon.orange {
    background: var(--brand-orange-100);
    color: var(--brand-orange-500);
}

.dialog-hero-icon.danger {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 62px;
    height: 62px;
    border-radius: 20px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-navy-50);
    color: var(--brand-navy-700);
    font-size: 1.55rem;
}

.empty-state h4 {
    color: var(--brand-navy-900);
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.88rem;
    max-width: 360px;
    margin: 0 auto;
}

/* Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--surface-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead th {
    background: var(--brand-navy-50);
    color: var(--brand-navy-900);
    font-weight: 800;
    text-align: right;
    padding: 12px 14px;
    border-bottom: 1.5px solid var(--border-light);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--surface-subtle);
}

/* Utility Helpers */
.hidden {
    display: none;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.flex-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    direction: ltr;
    unicode-bidi: embed;
}

@media (max-width: 900px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .card {
        padding: 15px;
        border-radius: var(--radius-md);
    }

    .toast-stack {
        left: 12px;
        right: 12px;
        top: 74px;
        max-width: none;
    }
}
