@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #090d16;
    --bg-secondary: rgba(17, 24, 39, 0.7);
    --bg-card: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent: #d946ef;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(217, 70, 239, 0.1) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Mobile Container - Responsive for iPhone + iPad */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: rgba(9, 13, 22, 0.85);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Desktop: phone frame */
@media (min-width: 481px) and (max-width: 1024px) {
    .app-container {
        height: 92vh;
        border-radius: 40px;
        border: 4px solid rgba(255, 255, 255, 0.08);
    }
}

/* iPad: wider layout */
@media (min-width: 768px) {
    .app-container {
        max-width: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .product-row {
        padding: 16px 24px;
    }
    .main-content {
        padding: 24px 32px 90px 32px;
    }
}

/* iPad Pro landscape */
@media (min-width: 1024px) {
    .app-container {
        max-width: 100%;
        flex-direction: row;
    }
    .nav-bar {
        flex-direction: column;
        width: 72px;
        height: 100%;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        position: relative;
        order: -1;
    }
    .main-content {
        flex: 1;
        padding: 32px 48px 32px 48px;
    }
    .metric-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Viewport structure */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 80px 20px;
    scroll-behavior: smooth;
}

.main-content::-webkit-scrollbar {
    width: 4px;
}

.main-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Screen visibility states */
.screen {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: block;
}

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

/* Auth / Login View */
.login-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.logo-header {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    width: 80px;
    height: 80px;
    border-radius: 24px;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px var(--primary-glow);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.logo-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(to right, #ffffff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.glass-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-style {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
}

.input-style:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    border-radius: 12px;
    padding: 15px;
    color: white;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 20px;
    display: none;
}

/* Navigation Bar at Bottom */
.nav-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    width: 60px;
    height: 100%;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    transition: var(--transition);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 6px var(--primary));
}

/* User Card and Profile Header */
.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    object-fit: cover;
}

.user-info h3 {
    font-size: 18px;
    font-weight: 600;
}

.user-info p {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* Dashboard Metrics & Layout */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    transition: var(--transition);
}

.metric-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.metric-icon.blue { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.metric-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.metric-icon.yellow { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.metric-icon.red { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.metric-val {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.metric-lbl {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Scanner and Camera view */
.scanner-viewport {
    width: 100%;
    aspect-ratio: 4/3;
    background: #020617;
    border-radius: 16px;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.scanner-laser {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--danger);
    top: 50%;
    left: 0;
    box-shadow: 0 0 8px var(--danger);
    animation: scanAnim 2s infinite linear;
}

@keyframes scanAnim {
    0% { top: 10%; }
    50% { top: 90%; }
    100% { top: 10%; }
}

/* Search and Lists styles */
.search-box-wrap {
    position: relative;
    margin-bottom: 16px;
}

.search-icon-inside {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-input-padding {
    padding-left: 44px;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-row {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.product-row:active {
    transform: scale(0.98);
}

.prod-thumbnail {
    width: 50px;
    height: 50px;
    min-width: 50px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
}

.prod-details {
    flex: 1;
    min-width: 0;
}

.prod-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.prod-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.prod-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--success);
}

/* Status dots/badges */
.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
}

.badge-success { 
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.15) 100%); 
    color: #6ee7b7; 
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-warning { 
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.15) 100%); 
    color: #fcd34d; 
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Skeleton loaders */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
}

@keyframes skeletonLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* QR Scanner emulation box */
.emulated-scanner-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

/* ─── Toast Notification System ─── */
#toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: min(92vw, 420px);
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 12px 18px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #f8fafc;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    width: 100%;
    pointer-events: all;
}

.toast-item.toast-hide {
    animation: toastOut 0.4s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.toast-success { border-color: rgba(16,185,129,0.4); }
.toast-success .toast-icon { color: #34d399; }

.toast-error { border-color: rgba(239,68,68,0.4); }
.toast-error .toast-icon { color: #f87171; }

.toast-warning { border-color: rgba(245,158,11,0.4); }
.toast-warning .toast-icon { color: #fbbf24; }

.toast-info { border-color: rgba(99,102,241,0.4); }
.toast-info .toast-icon { color: #818cf8; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0)  scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0)  scale(1); }
    to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ─── Navigation Badge ─── */
.nav-badge {
    position: absolute;
    top: 8px;
    right: 6px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* ─── Filter Buttons ─── */
.filter-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Outfit', sans-serif;
}
.filter-btn.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.3) 0%, rgba(217,70,239,0.2) 100%);
    border-color: rgba(99,102,241,0.5);
    color: #c7d2fe;
    box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.filter-btn:active { transform: scale(0.95); }

/* ─── Invoice Cards ─── */
.invoice-row {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.invoice-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 4px 0 0 4px;
}
.invoice-row:active { transform: scale(0.98); opacity: 0.8; }
.invoice-row .inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.invoice-row .inv-number {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.invoice-row .inv-date {
    font-size: 11px;
    color: var(--text-secondary);
}
.invoice-row .inv-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.invoice-row .inv-customer {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}
.invoice-row .inv-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
    letter-spacing: -0.3px;
}

/* ─── Back Button ─── */
.btn-back {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-back:active { transform: scale(0.9); }

/* ─── Invoice Detail Items ─── */
.inv-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin: 0 -12px;
    border-radius: 10px;
    transition: var(--transition);
}
.inv-item-row:nth-child(odd) {
    background: rgba(255,255,255,0.02);
}
.inv-item-row:last-child { border-bottom: none; }
.inv-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.3;
}
.inv-item-qty {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 12px;
    white-space: nowrap;
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 6px;
}
.inv-item-subtotal {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* ─── Payment Row ─── */
.payment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 13px;
}
.payment-row:last-child { border-bottom: none; }
.payment-method {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}
.payment-amount {
    font-weight: 700;
    color: var(--success);
}
.payment-date {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ─── Alerts Summary ─── */
.alerts-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.alert-summary-card {
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.alert-summary-card.red {
    background: linear-gradient(135deg, rgba(239,68,68,0.2) 0%, rgba(220,38,38,0.1) 100%);
    border: 1px solid rgba(239,68,68,0.3);
}
.alert-summary-card.yellow {
    background: linear-gradient(135deg, rgba(245,158,11,0.2) 0%, rgba(217,119,6,0.1) 100%);
    border: 1px solid rgba(245,158,11,0.3);
}
.alert-summary-val {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}
.alert-summary-card.red .alert-summary-val { color: #f87171; }
.alert-summary-card.yellow .alert-summary-val { color: #fbbf24; }
.alert-summary-lbl {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 500;
}

/* ─── Alert Product Row ─── */
.alert-row {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.alert-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}
.alert-row.out-of-stock {
    border-left: none;
}
.alert-row.out-of-stock::before {
    background: linear-gradient(180deg, #ef4444, #dc2626);
}
.alert-row.low-stock {
    border-left: none;
}
.alert-row.low-stock::before {
    background: linear-gradient(180deg, #f59e0b, #d97706);
}
.alert-row-info { flex: 1; padding-left: 8px; }
.alert-row-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}
.alert-row-sku {
    font-size: 12px;
    color: var(--text-secondary);
}
.alert-row-stock {
    text-align: right;
    padding: 10px 14px;
    border-radius: 12px;
}
.alert-row.out-of-stock .alert-row-stock {
    background: rgba(239,68,68,0.15);
}
.alert-row.low-stock .alert-row-stock {
    background: rgba(245,158,11,0.15);
}
.alert-row-stock-val {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}
.alert-row.out-of-stock .alert-row-stock-val { color: #f87171; }
.alert-row.low-stock .alert-row-stock-val { color: #fbbf24; }
.alert-row-stock-lbl {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ─── Small outline button ─── */
.btn-outline-sm {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Outfit', sans-serif;
}
.btn-outline-sm:active { transform: scale(0.95); }
