/**
 * Afribomba Design System
 * Atomic design tokens and reusable components for admin & frontend consistency.
 * Single source of truth for colors, typography, spacing, tables, buttons, and cards.
 */

/* ============================================
   DESIGN TOKENS (Atomic Variables)
   ============================================ */
:root {
    /* Colors - Semantic */
    --ds-primary: #6366f1;
    --ds-primary-dark: #4f46e5;
    --ds-secondary: #64748b;
    --ds-success: #10b981;
    --ds-warning: #f59e0b;
    --ds-danger: #ef4444;
    --ds-info: #0ea5e9;

    /* Neutral palette */
    --ds-slate-50: #f8fafc;
    --ds-slate-100: #f1f5f9;
    --ds-slate-200: #e2e8f0;
    --ds-slate-300: #cbd5e1;
    --ds-slate-400: #94a3b8;
    --ds-slate-500: #64748b;
    --ds-slate-600: #475569;
    --ds-slate-700: #334155;
    --ds-slate-800: #1e293b;
    --ds-slate-900: #0f172a;
    --ds-slate-950: #020617;

    /* Typography */
    --ds-font-sans: 'Outfit', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --ds-font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --ds-text-xs: 0.65rem;
    --ds-text-sm: 0.8rem;
    --ds-text-base: 0.9rem;
    --ds-text-lg: 1rem;
    --ds-text-xl: 1.25rem;
    --ds-text-2xl: 1.5rem;

    /* Spacing */
    --ds-space-1: 0.25rem;
    --ds-space-2: 0.5rem;
    --ds-space-3: 0.75rem;
    --ds-space-4: 1rem;
    --ds-space-5: 1.25rem;
    --ds-space-6: 1.5rem;
    --ds-space-8: 2rem;

    /* Radii */
    --ds-radius-sm: 8px;
    --ds-radius-md: 12px;
    --ds-radius-lg: 16px;
    --ds-radius-xl: 20px;

    /* Shadows */
    --ds-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --ds-shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
    --ds-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
    --ds-shadow-card: 0 10px 30px rgba(0, 0, 0, 0.3);

    /* Gradients */
    --ds-gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
    --ds-gradient-success: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
    --ds-gradient-warning: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    --ds-gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --ds-gradient-info: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    --ds-gradient-card: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Override with dynamic settings when available (injected by app.blade.php) */
:root {
    --primary-color: var(--ds-primary);
    --secondary-color: var(--ds-secondary);
}

/* ============================================
   UNIFIED TABLE COMPONENTS
   ============================================ */
.table-elite,
.table-modern,
.table-premium,
.elite-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--ds-text-sm);
    background: white;
    border-radius: var(--ds-radius-lg);
    overflow: hidden;
    box-shadow: var(--ds-shadow-sm);
}

.table-elite thead,
.table-modern thead,
.table-premium thead,
.elite-table thead {
    background: var(--ds-gradient-card) !important;
    color: white !important;
}

.table-elite thead th,
.table-modern thead th,
.table-premium thead th,
.elite-table thead th {
    padding: 1rem 1.25rem !important;
    font-weight: 700 !important;
    font-size: var(--ds-text-xs) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border: none !important;
}

.table-elite tbody tr,
.table-modern tbody tr,
.table-premium tbody tr,
.elite-table tbody tr {
    transition: background 0.2s;
}

.table-elite tbody tr:hover,
.table-modern tbody tr:hover,
.table-premium tbody tr:hover,
.elite-table tbody tr:hover {
    background: var(--ds-slate-50) !important;
}

.table-elite tbody td,
.table-modern tbody td,
.table-premium tbody td,
.elite-table tbody td,
.ledger-table tbody td {
    padding: 0.875rem 1.25rem !important;
    vertical-align: middle !important;
    border-bottom: 1px solid var(--ds-slate-200) !important;
}

.ledger-table thead th {
    background: var(--ds-gradient-primary) !important;
    color: white !important;
    padding: 1rem 1.5rem !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border: none !important;
}

.ledger-table tbody tr:hover {
    background: var(--ds-slate-50) !important;
}

/* ============================================
   UNIFIED BUTTON COMPONENTS
   ============================================ */
.btn-elite-primary,
.btn-primary-modern,
.elite-btn-primary {
    background: var(--ds-gradient-primary) !important;
    color: white !important;
    border: none !important;
    border-radius: var(--ds-radius-md) !important;
    padding: 0.5rem 1.25rem !important;
    font-weight: 700 !important;
    font-size: var(--ds-text-sm) !important;
    transition: all 0.2s !important;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3) !important;
}

.btn-elite-primary:hover,
.btn-primary-modern:hover,
.elite-btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4) !important;
}

.btn-elite-secondary,
.btn-secondary-modern,
.elite-btn-secondary {
    background: var(--ds-slate-100) !important;
    color: var(--ds-slate-700) !important;
    border: 1px solid var(--ds-slate-200) !important;
    border-radius: var(--ds-radius-md) !important;
    padding: 0.5rem 1.25rem !important;
    font-weight: 600 !important;
    font-size: var(--ds-text-sm) !important;
    transition: all 0.2s !important;
}

.btn-elite-secondary:hover,
.btn-secondary-modern:hover,
.elite-btn-secondary:hover {
    background: var(--ds-slate-200) !important;
    color: var(--ds-slate-900) !important;
}

/* ============================================
   HUD METRIC CARDS (Unified)
   ============================================ */
.metric-card-elite,
.hud-card-elite {
    background: var(--ds-gradient-card) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: var(--ds-radius-lg) !important;
    box-shadow: var(--ds-shadow-card) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.metric-card-elite .card-body,
.hud-card-elite .card-body {
    background: transparent !important;
}

.metric-card-elite h4,
.hud-card-elite h4 {
    color: white !important;
    font-family: var(--ds-font-mono) !important;
    font-size: 1.5rem !important;
    font-weight: 800 !important;
}

.metric-card-elite h6,
.hud-card-elite h6 {
    font-size: var(--ds-text-xs) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.7) !important;
}

.metric-card-elite .icon-box,
.hud-card-elite .icon-box {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.metric-card-elite:hover,
.hud-card-elite:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Border accent variants */
.metric-card-elite.border-left-primary::before,
.hud-card-elite.border-left-primary::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ds-gradient-primary);
    opacity: 0.8;
}

.metric-card-elite.border-left-info::before,
.hud-card-elite.border-left-info::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ds-gradient-info);
    opacity: 0.8;
}

.metric-card-elite.border-left-warning::before,
.hud-card-elite.border-left-warning::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ds-gradient-warning);
    opacity: 0.8;
}

.metric-card-elite.border-left-danger::before,
.hud-card-elite.border-left-danger::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ds-gradient-danger);
    opacity: 0.8;
}

/* ============================================
   LEDGER / CARD CONTAINER
   ============================================ */
.ledger-card-elite,
.card.shadow-sm.ledger-elite {
    background: white;
    border-radius: var(--ds-radius-xl);
    border: 1px solid var(--ds-slate-200);
    box-shadow: var(--ds-shadow-md);
    overflow: hidden;
}

.ledger-card-elite .card-header,
.card.shadow-sm.ledger-elite .card-header {
    background: linear-gradient(135deg, var(--ds-slate-50) 0%, var(--ds-slate-100) 100%) !important;
    border-bottom: 1px solid var(--ds-slate-200) !important;
    padding: 1.5rem !important;
}

.ledger-card-elite .card-header h5,
.card.shadow-sm.ledger-elite .card-header h5 {
    color: var(--ds-slate-800);
    font-weight: 700;
    font-size: 1.25rem;
}

/* ============================================
   FORM CONTROLS (Unified)
   ============================================ */
.form-control-modern,
.form-control.elite {
    border-radius: var(--ds-radius-md) !important;
    border: 1px solid var(--ds-slate-200) !important;
    padding: 0.5rem 1rem !important;
    font-size: var(--ds-text-sm) !important;
    transition: all 0.2s !important;
}

.form-control-modern:focus,
.form-control.elite:focus {
    border-color: var(--ds-primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

/* ============================================
   BADGES & PILLS
   ============================================ */
.badge-elite-success { background: rgba(16, 185, 129, 0.15); color: #059669; }
.badge-elite-warning { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.badge-elite-danger { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
.badge-elite-info { background: rgba(14, 165, 233, 0.15); color: #0284c7; }
.badge-elite-primary { background: rgba(99, 102, 241, 0.15); color: var(--ds-primary-dark); }

/* ============================================
   MOBILE STATS ROW (Shared)
   ============================================ */
.mobile-stats-row {
    background: var(--ds-gradient-card);
    border-radius: var(--ds-radius-lg);
    padding: 0.8rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--ds-shadow-card);
}

.stats-scroll-inner {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.small-stat-pill {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 100px;
    flex-shrink: 0;
}

.small-stat-pill .stat-abbrv {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.small-stat-pill strong {
    color: white;
    font-family: var(--ds-font-mono);
    font-size: 1rem;
    font-weight: 800;
}

/* ============================================
   MODAL STYLING (Unified)
   ============================================ */
.modal-elite .modal-content {
    border-radius: var(--ds-radius-xl) !important;
    border: none !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
}

.modal-elite .modal-header {
    background: var(--ds-gradient-card) !important;
    color: white !important;
    border-radius: var(--ds-radius-xl) var(--ds-radius-xl) 0 0 !important;
    padding: 1.25rem 1.5rem !important;
}

.modal-elite .modal-header .modal-title {
    font-weight: 700 !important;
    font-size: 1.25rem !important;
}

.modal-elite .modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* ============================================
   PAGE HEADER (Strategic / Elite Header)
   ============================================ */
.strategic-header,
.elite-page-header {
    background: var(--ds-gradient-primary);
    padding: 1.5rem 1.75rem;
    margin: -1.5rem -1.5rem 0 -1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--ds-shadow-md);
    backdrop-filter: blur(10px);
    border-radius: 0 0 var(--ds-radius-xl) var(--ds-radius-xl);
}

.strategic-header h1,
.elite-page-header h1 {
    font-family: var(--ds-font-sans);
    font-weight: 800;
    font-size: 1.75rem;
    color: white;
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
}

.strategic-header p,
.elite-page-header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: var(--ds-text-base);
    font-weight: 500;
}

.analytic-chip {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: var(--ds-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* HUD card grid container */
.category-hud,
.hud-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: -2.5rem;
    position: relative;
    z-index: 10;
    margin-bottom: 1.5rem;
}

/* Individual HUD card */
.hud-card {
    background: var(--ds-gradient-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--ds-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--ds-shadow-card);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.hud-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hud-value {
    color: white;
    font-size: 1.75rem;
    font-weight: 800;
    font-family: var(--ds-font-mono);
}

.hud-card-primary::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ds-gradient-primary); opacity: 0.8; }

/* ============================================
   UNIFIED FLASH MESSAGE (replaces positive-flash-message)
   ============================================ */
.flash-message,
.positive-flash-message {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 9999;
    padding: 1rem 1.5rem;
    border-radius: var(--ds-radius-md);
    box-shadow: var(--ds-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 280px;
    max-width: 420px;
    animation: flashSlideIn 0.3s ease-out;
}

.flash-message-success,
.positive-flash-message {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.flash-message-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.flash-message-text {
    font-size: var(--ds-text-sm);
    font-weight: 600;
}

.flash-message-close,
.close-flash-msg {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.flash-message-close:hover,
.close-flash-msg:hover {
    background: rgba(255,255,255,0.35);
}

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

/* ============================================
   STAT CARDS (Customer Profile, etc.)
   ============================================ */
.stat-card {
    padding: 1rem;
    height: 100%;
    border-radius: var(--ds-radius-lg);
    background: white;
    box-shadow: var(--ds-shadow-sm);
    border: none;
}

.stat-card-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.icon-primary { background: #eff6ff; color: #3b82f6; }
.stat-card-icon.icon-success { background: #f0fdf4; color: #16a34a; }
.stat-card-icon.icon-danger { background: #fef2f2; color: #ef4444; }
.stat-card-icon.icon-pink { background: #fdf2f8; color: #db2777; }

.customer-header-bg {
    background: var(--ds-gradient-card) !important;
    min-height: 200px;
}

.extra-small { font-size: 0.7rem !important; }

.rounded-elite { border-radius: var(--ds-radius-xl) !important; }
.customer-avatar-img { width: 140px; height: 140px; object-fit: cover; border-width: 5px !important; }
.customer-name-title { font-size: 2.2rem; letter-spacing: -1px; }
.btn-call-ghost { background: rgba(255,255,255,0.2) !important; border: none !important; }
.text-slate-900 { color: var(--ds-slate-900) !important; }

/* POS Terminal */
.pos-terminal-wrapper { margin-top: -25px; background: var(--ds-slate-50); }
.pos-product-section { background: var(--ds-slate-50); }
.pos-cart-header, .pos-cart-footer { background: linear-gradient(135deg, var(--ds-slate-50) 0%, #fff 100%); }
.pos-cart-body { background: #fff; }
.pos-mobile-fab { bottom: 25px; right: 25px; z-index: 1050; display: none; transition: 0.3s transform ease; }
.pos-mobile-fab-btn { width: 65px; height: 65px; border: 4px solid white; background: var(--ds-slate-700); box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.pos-mobile-fab-icon { font-size: 1.4rem; }
.pos-mobile-fab-badge { top: -5px; right: -5px; width: 25px; height: 25px; font-size: 0.7rem; border: 3px solid white; font-weight: 800; }
.modal-elite-content { border-radius: 20px; padding: 5px; }
.pos-modal-product-header { background: linear-gradient(135deg, var(--ds-slate-50) 0%, var(--ds-slate-100) 100%); border: 1px solid var(--ds-slate-200); }
.pos-modal-product-img { background: white; border-radius: 12px; padding: 5px; }
.pos-modal-product-thumb { width: 50px; height: 50px; object-fit: contain; }
.hud-card-success::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ds-gradient-success); opacity: 0.8; }
.hud-card-warning::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ds-gradient-warning); opacity: 0.8; }
.hud-card-info::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ds-gradient-info); opacity: 0.8; }
