/* easykargo/includes/styles.css */

:root {
    --primary: #1e3a8a;
    --primary-light: #3b82f6;
    --primary-hover: #172554;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 1rem;
    --radius-lg: 1.5rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.45);
}

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

html[dir="rtl"],
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"],
html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

/* ── Skip Navigation Link (Accessibility) ───────────────── */
.skip-link {
    position: absolute;
    top: -100%;
    right: 0;
    background: var(--primary);
    color: #fff;
    padding: .75rem 1.5rem;
    font-weight: 700;
    font-size: .95rem;
    z-index: 9999;
    border-radius: 0 0 .5rem .5rem;
    transition: top .2s;
}
.skip-link:focus {
    top: 0;
}

/* ── Focus Visible (WCAG 2.4.7) ─────────────────────────── */
:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 3px;
    border-radius: 4px;
}
:focus:not(:focus-visible) {
    outline: none;
}

/* ── Minimum Touch Target (Apple HIG / WCAG 2.5.5) ─────── */
.btn,
.nav-link,
button,
[role="button"] {
    min-height: 44px;
    min-width: 44px;
}
.btn-sm {
    min-height: 36px;
}

/* Page Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Header & Navigation */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
@media (min-width: 1800px) {
    .navbar { padding: 1rem 4rem; }
}
@media (max-width: 768px) {
    .navbar { padding: 1rem 1.25rem; }
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 850;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background-color: #f1f5f9;
}

/* Dropdown Menu Styles */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--bg-card);
    min-width: 200px;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 1000;
    padding: 0.5rem 0;
}

html[dir="ltr"] .dropdown-menu {
    right: auto;
    left: 0;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu {
    display: block;
    animation: fadeIn 0.2s ease;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-dark);
    font-weight: 600;
    transition: var(--transition);
}

.dropdown-item:hover, .dropdown-item.active {
    background-color: #f1f5f9;
    color: var(--primary);
}

/* ── Navbar counter ───────────────────────────────────────────────────
   Paid orders with no shipping label yet, on "متجري" so the seller sees the
   queue from every page instead of only on the orders list itself.

   Notification badge: a true red circle with the count in white. Width and
   height are equal and the radius is 50%, so one or two digits sit in a circle
   rather than a pill; three or more get .nav-badge-wide from the template,
   which relaxes it into a rounded rect instead of squashing the number. */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background-color: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    /* White ring lifts the dot off the navbar the way an app icon badge does */
    box-shadow: 0 0 0 2px var(--bg-card);
    /* Raised slightly so it reads as attached to the label, not part of it */
    position: relative;
    top: -0.4em;
    margin-inline-start: 0.3rem;
    vertical-align: middle;
}

/* 100+ would be clipped by a fixed-width circle */
.nav-badge-wide {
    width: auto;
    min-width: 1.3rem;
    padding: 0 0.35rem;
    border-radius: 999px;
}

/* Inside the dropdown the row is a block and sits on a hover-tinted surface,
   so the count goes to the far end and drops the ring and the lift. */
.nav-badge-inline {
    float: inline-end;
    top: 0;
    margin-inline-start: 0.5rem;
    box-shadow: none;
}

/* Announced to screen readers, invisible on screen */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-badge {
    background-color: #eff6ff;
    color: var(--primary-light);
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    padding: 2rem 3rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}
@media (min-width: 1800px) {
    .main-wrapper { padding: 2.5rem 4rem; max-width: 1800px; }
}
@media (max-width: 768px) {
    .main-wrapper { padding: 1.25rem; }
}

/* Auth Pages Styling */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(circle at top left, #eff6ff 0%, #f8fafc 100%);
}

.auth-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 3rem 2.5rem;
    max-width: 480px;
    width: 100%;
    border: 1px solid var(--border);
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 850;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-align: center;
}

.auth-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* Card Styling */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 750;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Grid System */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

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

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Form Styling */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: #f8fafc;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

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

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 0.375rem;
}

.btn-block {
    width: 100%;
}

/* Table Styling */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--bg-card);
    box-shadow: var(--shadow);
}

html[dir="rtl"] table {
    text-align: right;
}

html[dir="ltr"] table {
    text-align: left;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: #f1f5f9;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Status Badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-success {
    background-color: var(--success-light);
    color: #065f46;
}

.badge-danger {
    background-color: var(--danger-light);
    color: #991b1b;
}

.badge-warning {
    background-color: var(--warning-light);
    color: #92400e;
}

.badge-info {
    background-color: #eff6ff;
    color: #1e40af;
}

/* Dashboard Statistics Cards */
.stats-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.stats-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stats-info p {
    font-size: 1.6rem;
    font-weight: 850;
    color: var(--primary);
}

.stats-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stats-icon.blue { background-color: #eff6ff; color: var(--primary-light); }
.stats-icon.green { background-color: var(--success-light); color: var(--success); }
.stats-icon.yellow { background-color: var(--warning-light); color: var(--warning); }
.stats-icon.red { background-color: var(--danger-light); color: var(--danger); }

/* Alert Messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.alert-success {
    background-color: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Quick Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.w-full { width: 100%; }

/* Steps Navigation Indicator */
.steps-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
}

.steps-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--border);
    z-index: 1;
    transform: translateY(-50%);
}

.step-item {
    background-color: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    z-index: 2;
    transition: var(--transition);
}

.step-item.active {
    border-color: var(--primary-light);
    background-color: var(--primary-light);
    color: white;
}

.step-item.completed {
    border-color: var(--success);
    background-color: var(--success);
    color: white;
}

/* ── Reduce Motion (WCAG 2.3.3) ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── High Contrast Support ───────────────────────────────── */
@media (forced-colors: active) {
    .btn,
    .badge,
    .alert {
        border: 1px solid ButtonText;
    }
}

/* ── Mobile Navbar Improvements ─────────────────────────── */
@media (max-width: 480px) {
    .navbar {
        padding: .75rem 1rem;
        gap: .75rem;
    }
    .nav-brand {
        font-size: 1.2rem;
    }
    .nav-link {
        font-size: .82rem;
        padding: .4rem .6rem;
    }
    .main-wrapper {
        padding: 1rem;
    }
}

/* ── Required field indicator ────────────────────────────── */
.required {
    color: var(--danger);
    margin-right: .15rem;
    font-weight: 900;
}

/* ── Form hint text ──────────────────────────────────────── */
.form-hint {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

/* ── Error message in form ───────────────────────────────── */
.form-error {
    font-size: .82rem;
    color: var(--danger);
    font-weight: 600;
    margin-top: .2rem;
    display: none;
}
.form-control[aria-invalid="true"] {
    border-color: var(--danger);
    background-color: #fff5f5;
}
.form-control[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ── Shipping labels styling for print ───────────────────── */
@media print {
    body * {
        visibility: hidden;
    }
    .print-area,
    .print-area * {
        visibility: visible;
    }
    .print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
    }
}

/* ── Mobile Responsive Cards for Tables ───────────────────── */
.desktop-only {
    display: block;
}
.mobile-only {
    display: none !important;
}

/* Responsive Desktop vs Mobile visibility helpers */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: flex !important;
        flex-direction: column;
        gap: 1rem;
    }
    .table-container {
        border-radius: var(--radius);
        -webkit-overflow-scrolling: touch;
    }
    .table-container th, 
    .table-container td {
        padding: 0.75rem 0.85rem;
        font-size: 0.85rem;
    }
}

.mobile-shipment-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease-in-out;
}

.mobile-shipment-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px dashed var(--border);
}

.mobile-card-id {
    font-weight: 850;
    font-size: 1.1rem;
    color: var(--primary);
}

.mobile-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1rem;
    font-size: 0.9rem;
}

.mobile-card-item {
    display: flex;
    flex-direction: column;
}

.mobile-card-item.full-width {
    grid-column: span 2;
}

.mobile-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.mobile-card-value {
    font-weight: 700;
    color: var(--text-dark);
    word-break: break-word;
}

.mobile-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

