/* ==========================================================================
   BFG Order Alert – Modern Industrial Warehouse Styling
   ========================================================================== */

:root {
    --bg-primary: #07111f;
    --bg-secondary: #0d1b2a;
    --bg-tertiary: #13263a;
    --card-bg: rgba(19, 38, 58, 0.88);
    --card-border: rgba(0, 191, 255, 0.2);
    
    --primary: #00bfff;
    --primary-glow: rgba(0, 191, 255, 0.4);
    --success: #20d67b;
    --success-glow: rgba(32, 214, 123, 0.4);
    --warning: #ffb020;
    --warning-glow: rgba(255, 176, 32, 0.4);
    --danger: #ff3b5c;
    --danger-glow: rgba(255, 59, 92, 0.4);
    --purple: #a855f7;
    
    --text-primary: #ffffff;
    --text-secondary: #b8c5d6;
    --text-muted: #6c7a89;
    
    --header-height: 85px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-glow: 0 0 20px rgba(0, 191, 255, 0.25);
    
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Thai", sans-serif;
}

/* Light Theme Variables */
body.theme-light {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-border: rgba(0, 150, 255, 0.25);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
}

/* Base Setup */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

body.cursor-hidden {
    cursor: none !important;
}

body.cursor-hidden * {
    cursor: none !important;
}

/* Industrial Grid Background */
.bg-dark-industrial {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(0, 191, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(32, 214, 123, 0.04) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
}

/* Header Container */
.app-header {
    background: rgba(13, 27, 42, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 2px solid var(--card-border);
    padding: 0.5rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.brand-logo-img {
    height: 42px !important;
    max-height: 42px !important;
    width: auto !important;
    max-width: 140px !important;
    object-fit: contain;
    border-radius: 8px;
    filter: drop-shadow(0 2px 6px rgba(0, 191, 255, 0.3));
    transition: transform 0.2s ease;
}

.brand-logo-img:hover {
    transform: scale(1.04);
}

.brand-title {
    font-size: clamp(1.2rem, 1.8vw, 2.2rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: clamp(0.78rem, 0.9vw, 1.05rem);
    color: var(--text-secondary);
    font-weight: 500;
}

/* Connection Status Dot */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 30px;
    background: rgba(0,0,0,0.3);
    font-size: clamp(0.78rem, 0.9vw, 1.05rem);
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.1);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.status-dot.online {
    background-color: var(--success);
    box-shadow: 0 0 12px var(--success);
    animation: pulseDot 2s infinite;
}

.status-dot.offline {
    background-color: var(--danger);
    box-shadow: 0 0 12px var(--danger);
    animation: pulseDotDanger 1s infinite;
}

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

@keyframes pulseDotDanger {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

/* Time & Clock Display */
.clock-display {
    text-align: right;
}

.clock-time {
    font-size: clamp(1.5rem, 2vw, 2.5rem);
    font-weight: 800;
    font-family: monospace, var(--font-main);
    color: var(--primary);
    line-height: 1;
    letter-spacing: 1px;
    text-shadow: 0 0 15px var(--primary-glow);
}

.clock-date {
    font-size: clamp(0.8rem, 0.95vw, 1.15rem);
    color: var(--text-secondary);
    font-weight: 600;
}

/* Control Buttons */
.btn-hdr-ctrl {
    background: var(--bg-tertiary);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: clamp(0.82rem, 0.9vw, 1.05rem);
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-hdr-ctrl:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

/* Summary Dashboard Cards */
.summary-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(10px);
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: var(--card-accent-color, var(--primary));
}

.summary-icon {
    font-size: clamp(1.4rem, 1.8vw, 2.2rem);
    opacity: 0.85;
}

.summary-number {
    font-size: clamp(1.8rem, 2.4vw, 3rem);
    font-weight: 900;
    line-height: 1;
    margin-top: 0.15rem;
    color: var(--text-primary);
}

.summary-label {
    font-size: clamp(0.78rem, 0.9vw, 1.05rem);
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 0.2rem;
}

/* Summary Theme Colors */
.card-new { --card-accent-color: var(--primary); }
.card-new .summary-number { color: var(--primary); }

.card-pending { --card-accent-color: var(--warning); }
.card-pending .summary-number { color: var(--warning); }

.card-processing { --card-accent-color: var(--purple); }
.card-processing .summary-number { color: var(--purple); }

.card-completed { --card-accent-color: var(--success); }
.card-completed .summary-number { color: var(--success); }

.card-depts { --card-accent-color: #38bdf8; }
.card-depts .summary-number { color: #38bdf8; }

.card-wait { --card-accent-color: var(--danger); }
.card-wait .summary-number { color: var(--danger); }

/* Filter Tabs & Search Bar */
.filter-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-tab-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0.45rem 1.1rem;
    border-radius: 30px;
    font-size: clamp(0.85rem, 0.95vw, 1.05rem);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-tab-btn:hover, .nav-tab-btn.active {
    background: var(--primary);
    color: #07111f;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.search-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    border-radius: 30px;
    padding: 0.45rem 1.1rem;
    font-size: clamp(0.85rem, 0.95vw, 1.05rem);
    width: 100%;
}

.search-input:focus {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    outline: none;
}

/* Order Card Styling */
.order-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    overflow: hidden;
}

.order-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background-color: var(--status-color, var(--primary));
}

/* Status-specific card borders */
.order-card[data-status="รอดำเนินการ"] { --status-color: var(--warning); }
.order-card[data-status="กำลังจัดสินค้า"] { --status-color: var(--purple); }
.order-card[data-status="พร้อมจ่าย"] { --status-color: #38bdf8; }
.order-card[data-status="เสร็จสิ้น"] { --status-color: var(--success); opacity: 0.85; }
.order-card[data-status="ยกเลิก"] { --status-color: var(--text-muted); opacity: 0.6; }

/* Overdue Urgency States */
.order-card.urgency-warning {
    border-color: var(--warning);
}

.order-card.urgency-orange {
    border-color: #f97316;
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.4);
}

.order-card.urgency-urgent {
    border-color: var(--danger);
    box-shadow: 0 0 25px var(--danger-glow);
    animation: urgentPulse 1.8s infinite ease-in-out;
}

@keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 15px var(--danger-glow); }
    50% { box-shadow: 0 0 35px rgba(255, 59, 92, 0.8); }
}

/* NEW Order Glow Animation */
.order-card.is-new-card {
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
    animation: newCardSlide 0.6s ease-out, newGlowPulse 2s infinite alternate;
}

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

@keyframes newGlowPulse {
    from { box-shadow: 0 0 15px var(--primary-glow); }
    to { box-shadow: 0 0 35px rgba(0, 191, 255, 0.9); }
}

/* Card Badge */
.badge-new {
    background: linear-gradient(135deg, #00bfff, #0077ff);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 900;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 0 10px var(--primary-glow);
    animation: badgePulse 1s infinite alternate;
}

@keyframes badgePulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.badge-overdue {
    background: var(--danger);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 20px;
    animation: badgePulse 1s infinite alternate;
}

.bill-number {
    font-size: clamp(1.25rem, 1.5vw, 1.8rem);
    font-weight: 900;
    color: #ffffff;
    font-family: monospace, var(--font-main);
    letter-spacing: 0.5px;
}

.dept-name {
    font-size: clamp(1.05rem, 1.25vw, 1.45rem);
    font-weight: 800;
    color: var(--primary);
}

.emp-name {
    font-size: clamp(0.88rem, 0.95vw, 1.12rem);
    color: var(--text-secondary);
    font-weight: 600;
}

/* Signature Status Badges */
.signature-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 8px;
    font-size: clamp(0.78rem, 0.9vw, 1.1rem);
    font-weight: 700;
    line-height: 1.2;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.signature-badge.signed {
    background: rgba(32, 214, 123, 0.16);
    color: #20d67b;
    border: 1px solid rgba(32, 214, 123, 0.45);
    box-shadow: 0 0 8px rgba(32, 214, 123, 0.15);
}

.signature-badge.partial {
    background: rgba(255, 176, 32, 0.16);
    color: #ffb020;
    border: 1px solid rgba(255, 176, 32, 0.45);
}

.signature-badge.unsigned {
    background: rgba(255, 59, 92, 0.15);
    color: #ff3b5c;
    border: 1px solid rgba(255, 59, 92, 0.4);
}

.item-summary-box {
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.9rem;
    margin: 0.65rem 0;
    border: 1px solid rgba(255,255,255,0.06);
}

.item-count-text {
    font-size: clamp(0.95rem, 1.1vw, 1.35rem);
    font-weight: 800;
    color: #ffffff;
}

.time-badge {
    background: rgba(255,255,255,0.08);
    padding: 3px 9px;
    border-radius: 8px;
    font-size: clamp(0.8rem, 0.9vw, 1.05rem);
    font-weight: 600;
    color: var(--text-secondary);
}

/* Card Action Buttons */
.btn-card-action {
    font-size: clamp(0.88rem, 0.95vw, 1.12rem);
    font-weight: 800;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.btn-start-pick {
    background: linear-gradient(135deg, #a855f7, #7e22ce);
    color: #fff;
}
.btn-start-pick:hover {
    background: linear-gradient(135deg, #c084fc, #9333ea);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.5);
}

.btn-finish-pick {
    background: linear-gradient(135deg, #20d67b, #15803d);
    color: #fff;
}
.btn-finish-pick:hover {
    background: linear-gradient(135deg, #4ade80, #166534);
    box-shadow: 0 0 15px rgba(32, 214, 123, 0.5);
}

.btn-view-detail {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-view-detail:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* SweetAlert Custom Popup Styling */
.swal2-popup.warehouse-alert-popup {
    background: var(--bg-secondary) !important;
    border: 3px solid var(--primary) !important;
    border-radius: 24px !important;
    color: var(--text-primary) !important;
    box-shadow: 0 0 50px rgba(0, 191, 255, 0.6) !important;
    font-family: var(--font-main) !important;
    padding: 2rem !important;
}

.swal2-title.warehouse-alert-title {
    font-size: clamp(2rem, 3vw, 3.5rem) !important;
    font-weight: 900 !important;
    color: var(--primary) !important;
}

.bell-shake-icon {
    font-size: 4rem;
    animation: bellShake 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}

@keyframes bellShake {
    0% { transform: rotate(0); }
    15% { transform: rotate(25deg); }
    30% { transform: rotate(-20deg); }
    45% { transform: rotate(15deg); }
    60% { transform: rotate(-10deg); }
    75% { transform: rotate(5deg); }
    100% { transform: rotate(0); }
}

/* Modal Dark Theme Overrides */
.modal-content.dark-modal {
    background-color: #0b1524;
    border: 2px solid #00bfff;
    border-radius: 20px;
    color: #ffffff !important;
    box-shadow: 0 0 40px rgba(0, 191, 255, 0.3);
}

.modal-header.dark-modal-header {
    border-bottom: 1px solid rgba(0, 191, 255, 0.3);
    background: #07111f;
}

.modal-footer.dark-modal-footer {
    border-top: 1px solid rgba(0, 191, 255, 0.3);
    background: #07111f;
}

/* Modal Meta Box High Contrast */
.modal-meta-box {
    background: #0d1b2a !important;
    border: 1px solid rgba(0, 191, 255, 0.3) !important;
}

.modal-meta-label {
    color: #94a3b8 !important;
    font-size: 0.95rem;
    font-weight: 600;
}

.modal-meta-value {
    color: #ffffff !important;
    font-size: 1.25rem;
    font-weight: 800;
}

/* Table Dark Custom High Contrast */
.table-dark-custom {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.table-dark-custom th {
    background: #1e293b !important;
    color: #38bdf8 !important;
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    border-bottom: 2px solid #00bfff !important;
    padding: 0.85rem 1rem !important;
}

.table-dark-custom td {
    background: #0f172a !important;
    color: #ffffff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    vertical-align: middle !important;
    font-size: 1.15rem !important;
    padding: 0.85rem 1rem !important;
}

.table-dark-custom tr:nth-child(even) td {
    background: #132035 !important;
}

/* Product ID Code Badge High Contrast */
.table-dark-custom code, .code-badge {
    background: #1e293b !important;
    color: #ffea00 !important; /* Bright Yellow */
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    border: 1px solid #3b82f6 !important;
    font-family: monospace, var(--font-main) !important;
    display: inline-block;
}

.table-dark-custom .product-name-text {
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 1.15rem !important;
}

.table-dark-custom .quantity-text {
    color: #38bdf8 !important;
    font-weight: 900 !important;
    font-size: 1.3rem !important;
}

.table-dark-custom .remark-text {
    color: #e2e8f0 !important;
    font-weight: 500 !important;
}

.table-dark-custom .no-proof-text {
    color: #94a3b8 !important;
    font-weight: 600 !important;
}

/* Side Offcanvas Settings Panel */
.offcanvas.dark-offcanvas {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-left: 2px solid var(--card-border);
}

.form-label-lg {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Media Queries for TV and Mobile */
@media (min-width: 1920px) {
    .container-fluid {
        padding-left: 2.5rem;
        padding-right: 2.5rem;
    }
}

@media (max-width: 768px) {
    .brand-title {
        font-size: 1.5rem;
    }
    .clock-time {
        font-size: 1.6rem;
    }
    .order-card {
        padding: 1rem;
    }
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Audio Overlay Hide Guarantee */
#audioStartOverlay.d-none,
#audioStartOverlay[style*="display: none"] {
    display: none !important;
}
