/* ==========================================================================
   Infinity Plus Warehouse - Main Application Layout and Feature Styles
   Mobile-First Responsive App Shell
   ========================================================================== */

/* Login Screen */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    background:
        radial-gradient(circle at 18% 18%, rgba(232, 93, 26, 0.22), transparent 44%),
        radial-gradient(circle at 82% 84%, rgba(29, 124, 158, 0.28), transparent 48%),
        linear-gradient(145deg, var(--brand-navy-950) 0%, var(--brand-navy-900) 55%, var(--brand-navy-800) 100%);
}

.login-screen.is-hidden {
    display: none;
}

.login-card {
    width: 100%;
    max-width: 380px;
    margin: auto;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    padding: 22px 24px;
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.34);
    animation: modalPop 0.36s var(--ease-spring);
}

.login-brand {
    text-align: center;
    margin-bottom: 16px;
}

.login-logo {
    width: 128px;
    height: auto;
    margin: 0 auto 8px;
    object-fit: contain;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-footer-link {
    margin-top: 14px;
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.login-footer-link a {
    color: var(--brand-orange-600);
    font-weight: 800;
}

/* App Shell */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-shell.is-locked {
    display: none;
}

/* Top Header - Semi-Transparent Frosted Glass */
.topbar {
    position: sticky;
    top: 0;
    z-index: 400;
    height: var(--header-height);
    background: rgba(243, 246, 250, 0.7);
    backdrop-filter: blur(18px) saturate(175%);
    -webkit-backdrop-filter: blur(18px) saturate(175%);
    border-bottom: 1px solid rgba(14, 77, 100, 0.1);
    box-shadow: 0 4px 18px rgba(11, 57, 75, 0.05);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.menu-toggle-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand-navy-50);
    color: var(--brand-navy-900);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.topbar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.topbar-brand-name {
    font-weight: 900;
    font-size: 1rem;
    color: var(--brand-navy-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-brand-user {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--brand-orange-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Connection Status Pill (No Manual Sync Button) */
.connection-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: var(--radius-full);
    background: var(--status-success-bg);
    color: var(--status-success);
    font-size: 0.8rem;
    font-weight: 800;
    border: 1px solid rgba(15, 157, 88, 0.2);
}

.connection-pill.is-local {
    background: var(--brand-orange-100);
    color: var(--brand-orange-700);
    border-color: rgba(232, 93, 26, 0.24);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulseDot 2s infinite;
}

/* Single Unified Global Refresh Button */
.global-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    background: var(--brand-navy-800);
    color: #FFFFFF;
    font-weight: 700;
    font-size: 0.84rem;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.2s ease, transform 0.18s var(--ease-spring);
}

.global-refresh-btn:hover {
    background: var(--brand-orange-500);
    transform: translateY(-1px);
}

.global-refresh-btn:active {
    transform: scale(0.96);
}

/* Body Layout */
.app-body {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(7, 38, 51, 0.52);
    backdrop-filter: blur(3px);
}

.sidebar-overlay.is-open {
    display: block;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand-navy-950) 0%, var(--brand-navy-900) 65%, #0D4459 100%);
    color: var(--text-on-dark);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.74rem;
    font-weight: 800;
    color: rgba(248, 250, 252, 0.52);
    padding: 10px 12px 4px;
    letter-spacing: 0.02em;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border-radius: 13px;
    color: rgba(248, 250, 252, 0.84);
    font-weight: 700;
    font-size: 0.93rem;
    text-align: right;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.16s ease;
    position: relative;
}

.nav-item i {
    width: 22px;
    text-align: center;
    font-size: 1rem;
    color: rgba(248, 250, 252, 0.68);
    transition: color 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}

.nav-item.is-active {
    background: linear-gradient(135deg, var(--brand-orange-500), var(--brand-orange-600));
    color: #FFFFFF;
    box-shadow: 0 8px 20px rgba(232, 93, 26, 0.34);
}

.nav-item.is-active i {
    color: #FFFFFF;
}

.nav-item.is-hidden-perm {
    display: none;
}

.nav-badge {
    margin-right: auto;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 800;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    font-weight: 700;
    font-size: 0.88rem;
    transition: background-color 0.2s ease;
}

.sidebar-admin-link:hover {
    background: rgba(232, 93, 26, 0.88);
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(220, 38, 38, 0.18);
    color: #FECACA;
    font-weight: 700;
    font-size: 0.88rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

/* Main Content Area - Edge-to-Edge Full Width on Desktop */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 18px 20px 32px;
    max-width: none;
    width: 100%;
}

.tab-pane {
    display: none;
    animation: fadeSlideUp 0.28s var(--ease-spring);
}

.tab-pane.is-active {
    display: block;
}

/* Page Hero Banner */
.section-hero {
    background: linear-gradient(135deg, var(--brand-navy-950) 0%, var(--brand-navy-900) 52%, var(--brand-navy-800) 100%);
    color: #FFFFFF;
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.section-hero > * {
    position: relative;
    z-index: 2;
}

.section-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(115deg, rgba(255, 255, 255, 0.06) 0%, transparent 48%, rgba(232, 93, 26, 0.14) 100%);
    pointer-events: none;
}

.section-hero::after {
    content: '';
    position: absolute;
    left: -70px;
    top: -90px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    z-index: 0;
    border: 28px solid rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.section-hero .btn {
    border-radius: 12px;
    padding: 10px 18px;
}

.section-hero .btn-soft-orange {
    background: rgba(255, 255, 255, 0.14);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.section-hero .btn-soft-orange:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.section-hero h2 {
    font-size: 1.32rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.section-hero h2 i {
    color: var(--brand-orange-400);
}

.section-hero p {
    font-size: 0.88rem;
    color: rgba(248, 250, 252, 0.8);
}

/* KPI Stat Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    background: var(--surface-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease;
}

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

.kpi-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 900;
    color: var(--brand-navy-900);
    line-height: 1.1;
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-icon.navy { background: var(--brand-navy-100); color: var(--brand-navy-800); }
.kpi-icon.orange { background: var(--brand-orange-100); color: var(--brand-orange-500); }
.kpi-icon.danger { background: var(--status-danger-bg); color: var(--status-danger); }
.kpi-icon.success { background: var(--status-success-bg); color: var(--status-success); }

/* Sub-tabs Segmented Bar */
.subtabs-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    background: var(--surface-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-xs);
}

.subtab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.88rem;
    color: var(--text-secondary);
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.subtab-btn:hover {
    background: var(--surface-hover);
    color: var(--brand-navy-900);
}

.subtab-btn.is-active {
    background: var(--brand-navy-800);
    color: #FFFFFF;
    box-shadow: var(--shadow-xs);
}

.subtab-panel {
    display: none;
    animation: fadeSlideUp 0.24s var(--ease-spring);
}

.subtab-panel.is-active {
    display: block;
}

/* Filter Chips */
.filter-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    background: var(--surface-card);
    border: 1.5px solid var(--border-light);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.84rem;
    transition: all 0.18s ease;
}

.filter-chip:hover {
    border-color: var(--brand-navy-700);
    color: var(--brand-navy-900);
}

.filter-chip.is-active {
    background: var(--brand-navy-800);
    border-color: var(--brand-navy-800);
    color: #FFFFFF;
}

.filter-chip.orange-active.is-active {
    background: var(--brand-orange-500);
    border-color: var(--brand-orange-500);
    color: #FFFFFF;
}

.chip-count {
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.75rem;
    font-weight: 800;
}

.filter-chip.is-active .chip-count {
    background: rgba(255, 255, 255, 0.22);
    color: #FFFFFF;
}

/* Shortage Item Cards with Lightweight Product Image Thumbnail BEFORE Barcode */
.shortages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortage-card {
    background: var(--surface-card);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.shortage-card:hover {
    border-color: rgba(14, 77, 100, 0.35);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.shortage-card.is-selected {
    border-color: var(--brand-orange-500);
    background: var(--brand-orange-50);
}

.shortage-card-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 240px;
}

.shortage-check {
    width: 21px;
    height: 21px;
    accent-color: var(--brand-orange-500);
    cursor: pointer;
    flex-shrink: 0;
}

/* Product Photo Slot Positioned Before Barcode and Info */
.product-thumb-box {
    width: 66px;
    height: 66px;
    border-radius: 14px;
    border: 1.5px solid var(--border-light);
    background: var(--surface-subtle);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s var(--ease-spring), border-color 0.2s ease;
}

.product-thumb-box:hover {
    transform: scale(1.05);
    border-color: var(--brand-orange-500);
}

.product-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #FFFFFF;
    padding: 3px;
}

.product-thumb-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    padding: 4px;
}

.product-thumb-placeholder i {
    font-size: 1.2rem;
    color: var(--brand-navy-600);
    opacity: 0.65;
}

.shortage-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.shortage-name {
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

.shortage-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.barcode-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-light);
    color: var(--brand-navy-900);
    font-weight: 700;
    font-size: 0.8rem;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.barcode-pill:hover {
    background: var(--brand-navy-100);
    border-color: var(--brand-navy-700);
}

.shortage-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bulk-action-bar {
    position: sticky;
    bottom: 16px;
    z-index: 200;
    margin-top: 14px;
    padding: 13px 18px;
    border-radius: var(--radius-md);
    background: var(--brand-navy-900);
    color: #FFFFFF;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-lg);
    animation: fadeSlideUp 0.24s var(--ease-spring);
}

.bulk-action-bar.is-visible {
    display: flex;
}

/* Expiry Status Accent Borders */
.expiry-row-expired {
    background: #FFF5F5;
}

.expiry-row-critical {
    background: #FFFBEB;
}

/* Scanner Box */
.scanner-viewport {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--brand-navy-950);
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.72);
    border: 2px solid rgba(14, 77, 100, 0.3);
}

.product-lookup-card {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-navy-50), #FFFFFF);
    border: 1.5px solid rgba(14, 77, 100, 0.2);
}

.product-lookup-photo {
    width: 112px;
    height: 112px;
    border-radius: 16px;
    background: #FFFFFF;
    border: 1.5px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

/* HR Attendance Hero */
.hr-clock-card {
    background: linear-gradient(135deg, var(--brand-navy-900), var(--brand-navy-800));
    color: #FFFFFF;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.hr-clock-time {
    font-size: 2.35rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    margin: 6px 0;
}

.hr-clock-date {
    font-size: 0.9rem;
    color: rgba(248, 250, 252, 0.78);
    margin-bottom: 18px;
}

/* Image Lightbox */
.lightbox-img {
    width: 100%;
    max-height: 62vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    border: 1px solid var(--border-light);
    padding: 10px;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 450;
    height: var(--mobile-nav-height);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -6px 20px rgba(11, 57, 75, 0.08);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    align-items: center;
    justify-content: space-around;
}

.mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 800;
    transition: color 0.18s ease, background-color 0.18s ease;
}

.mobile-nav-btn i {
    font-size: 1.12rem;
}

.mobile-nav-btn.is-active {
    color: var(--brand-orange-600);
    background: var(--brand-orange-50);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .menu-toggle-btn {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        z-index: 600;
        transform: translateX(100%);
        transition: transform 0.28s var(--ease-spring);
        padding-top: 22px;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .main-content {
        padding: 16px 14px calc(var(--mobile-nav-height) + 28px);
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .bulk-action-bar {
        bottom: calc(var(--mobile-nav-height) + 10px);
    }

    .topbar {
        padding: 0 12px;
    }

    .global-refresh-btn span {
        display: none;
    }

    .global-refresh-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    .connection-pill {
        padding: 6px 10px;
        font-size: 0.72rem;
        white-space: nowrap;
    }
}

@media (max-width: 560px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .kpi-card {
        padding: 12px 13px;
    }

    .kpi-value {
        font-size: 1.35rem;
    }

    .kpi-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .section-hero {
        padding: 16px;
    }

    .section-hero h2 {
        font-size: 1.12rem;
    }

    .shortage-card {
        padding: 12px;
    }

    .shortage-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .product-thumb-box {
        width: 58px;
        height: 58px;
    }
}

/* Print Layout for Vouchers, Daily Sheet, and Periodic Inventory */
.print-only-sheet {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }

    .print-only-sheet,
    .print-only-sheet * {
        visibility: visible;
    }

    .print-only-sheet {
        display: block;
        position: fixed;
        inset: 0;
        background: #FFFFFF;
        padding: 20px;
        color: #000000;
    }
}
