/* Custom styles for the Inventory Management System */

/* Variables */
:root {
    --bg-dark-glow: radial-gradient(circle at 50% -20%, #1e1b4b 0%, #09090b 100%);
    --accent-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --border-glow: rgba(99, 102, 241, 0.2);
}

body {
    background: var(--bg-dark-glow);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #f4f4f5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Panel */
.glass-panel {
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.glass-panel:hover {
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active Navigation Item */
.nav-active {
    background: rgba(99, 102, 241, 0.15);
    border-left: 4px solid #6366f1;
    color: #a5b4fc;
}

/* Mobile Bottom Navigation active reset (for both light and dark themes) */
body .mobile-nav-item.nav-active {
    background: none !important;
    border-left: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #09090b;
}
::-webkit-scrollbar-thumb {
    background: #27272a;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}

/* Keyframes & Animations */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.2);
        border-color: rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
        border-color: rgba(239, 68, 68, 0.8);
    }
}

.pulse-glow-red {
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-in {
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Scan Barcode Animation overlay */
@keyframes laser {
    0% {
        top: 0%;
    }
    50% {
        top: 100%;
    }
    100% {
        top: 0%;
    }
}

.scanner-laser {
    width: 100%;
    height: 3px;
    background-color: #ef4444;
    position: absolute;
    animation: laser 2s infinite linear;
    box-shadow: 0 0 8px #ef4444;
}

/* Force Html5Qrcode video tag to fill the aspect-ratio container correctly on mobile */
#camera-scanner-view video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 12px;
}

@media print {
    /* Hide all background views and layouts */
    #app-layout, #login-screen, #toast-container, #scanner-modal, #device-modal, #component-modal {
        display: none !important;
    }
    
    /* Make the print modal take up the whole screen without background dimming */
    #print-modal {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 50mm !important;
        height: 30mm !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        display: block !important;
    }
    
    /* Hide the header and modal wrapper styling */
    #print-modal > div {
        border: none !important;
        box-shadow: none !important;
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 50mm !important;
        height: 30mm !important;
    }
    
    /* Hide the header bar of the modal */
    #print-modal > div > div:first-child {
        display: none !important;
    }
    
    /* Hide the action buttons inside the modal body */
    #print-modal > div > div:last-child > div:last-child {
        display: none !important;
    }
    
    /* Style the body container of the print modal */
    #print-modal > div > div:last-child {
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
        width: 50mm !important;
        height: 30mm !important;
    }
    
    /* Style the printable badge to occupy exactly 50x30mm */
    #printable-badge {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 50mm !important;
        height: 30mm !important;
        padding: 2mm !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        background: white !important;
        color: black !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    #print-barcode-svg {
        width: 100% !important;
        height: auto !important;
        max-height: 12mm !important;
        display: block !important;
        margin: 1mm 0 !important;
    }
    
    #print-barcode-svg.device-barcode {
        max-height: 14.5mm !important;
    }
    
    @page label-page {
        size: 50mm 30mm;
        margin: 0 !important;
    }
    #print-modal {
        page: label-page !important;
    }
}


/* ==========================================================================
   THEME DESIGN SYSTEM (LIGHT THEME OVERRIDES)
   ========================================================================== */

/* Light Theme Variables and Class Overrides */
body.light-theme {
    background: radial-gradient(circle at 50% -20%, #f1f5f9 0%, #cbd5e1 100%) !important;
    background-color: #f8fafc !important;
    color: #1e293b !important;
}

body.light-theme .glass-panel {
    background: rgba(255, 255, 255, 0.75) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.04) !important;
}

body.light-theme .glass-panel:hover {
    border-color: rgba(99, 102, 241, 0.4) !important;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.05) !important;
}

body.light-theme .bg-dark-200 {
    background-color: #f1f5f9 !important;
}

body.light-theme .bg-dark-100 {
    background-color: #e2e8f0 !important;
}

body.light-theme .bg-dark-100\/40 {
    background-color: rgba(226, 232, 240, 0.4) !important;
}

body.light-theme .bg-dark-100\/50 {
    background-color: rgba(226, 232, 240, 0.5) !important;
}

body.light-theme .bg-dark-100\/95 {
    background-color: rgba(226, 232, 240, 0.95) !important;
}

body.light-theme .text-gray-100 {
    color: #1e293b !important;
}

body.light-theme .text-white {
    color: #0f172a !important;
}

body.light-theme .text-gray-300 {
    color: #334155 !important;
}

body.light-theme .text-gray-400 {
    color: #475569 !important;
}

body.light-theme .text-gray-500 {
    color: #64748b !important;
}

body.light-theme .border-gray-800 {
    border-color: #cbd5e1 !important;
}

body.light-theme .border-gray-800\/50 {
    border-color: rgba(203, 213, 225, 0.5) !important;
}

body.light-theme .border-gray-850 {
    border-color: #94a3b8 !important;
}

body.light-theme .divide-gray-800\/50 > * + * {
    border-color: rgba(203, 213, 225, 0.5) !important;
}

body.light-theme .hover\:bg-gray-800\/10:hover {
    background-color: rgba(99, 102, 241, 0.05) !important;
}

body.light-theme .hover\:bg-gray-800\/40:hover {
    background-color: rgba(99, 102, 241, 0.1) !important;
}

body.light-theme input, 
body.light-theme select, 
body.light-theme textarea {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

body.light-theme input::placeholder, 
body.light-theme textarea::placeholder {
    color: #94a3b8 !important;
}

body.light-theme .nav-active {
    background: rgba(99, 102, 241, 0.1) !important;
    border-left: 4px solid #4f46e5 !important;
    color: #4f46e5 !important;
}

body.light-theme .mobile-nav-item.text-brand-500 {
    color: #4f46e5 !important;
}

body.light-theme .text-brand-400 {
    color: #4f46e5 !important;
}

body.light-theme .text-brand-300 {
    color: #4338ca !important;
}

body.light-theme .bg-brand-500\/10 {
    background-color: rgba(79, 70, 229, 0.1) !important;
}

body.light-theme .border-brand-500\/20 {
    border-color: rgba(79, 70, 229, 0.2) !important;
}

body.light-theme ::-webkit-scrollbar-track {
    background: #f1f5f9;
}

body.light-theme ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================================================
   MOBILE RESPONSIVE TABLES (STACK CARDS)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Turn tables into grid list layout */
    table thead {
        display: none !important;
    }
    
    table, table tbody, table tr, table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    table tr {
        margin-bottom: 16px !important;
        background: rgba(30, 30, 40, 0.3) !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        border-radius: 16px !important;
        padding: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    }
    
    body.light-theme table tr {
        background: rgba(255, 255, 255, 0.9) !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04) !important;
    }
    
    table td {
        padding: 8px 4px !important;
        border: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: right !important;
        gap: 12px !important;
    }
    
    body.light-theme table td {
        border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
    }
    
    table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 11px;
        color: #6366f1;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: left;
        flex-shrink: 0;
    }
    
    body.light-theme table td::before {
        color: #4f46e5 !important;
    }
    
    /* Hide label if empty or selectors */
    table td[data-label=""]::before,
    table td[data-label="Seleziona"]::before {
        display: none !important;
    }
    
    table td:last-child {
        border-bottom: none !important;
        justify-content: space-between !important;
        padding-top: 12px !important;
    }
    
    /* Optimize main info block (components/devices) on mobile card view */
    table td[data-label="Componente"],
    table td[data-label="Dispositivo"] {
        display: block !important;
        text-align: left !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding-bottom: 12px !important;
        margin-bottom: 8px !important;
    }
    
    table td[data-label="Componente"]::before,
    table td[data-label="Dispositivo"]::before {
        display: none !important;
    }
    
    body.light-theme table td[data-label="Componente"],
    body.light-theme table td[data-label="Dispositivo"] {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    }
}

/* ==========================================================================
   INTERACTIVE WAREHOUSE MAP
   ========================================================================== */
.shelf-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    padding: 8px 0;
}

.shelf-card {
    background: rgba(24, 24, 27, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-align: center;
}

body.light-theme .shelf-card {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.08);
}

.shelf-card:hover {
    transform: translateY(-4px);
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

body.light-theme .shelf-card:hover {
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.1);
}

.shelf-card.shelf-selected {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}


/* Mobile Sidebar Open style */
@media screen and (max-width: 768px) {
    #sidebar-menu.mobile-open {
        display: flex !important;
        transform: translateX(0) !important;
        width: 80% !important;
        max-width: 300px !important;
    }
}

/* Large Shelf Card specific overrides */
.shelf-card.shelf-large {
    height: 140px;
    border-width: 2px;
}

body.light-theme .shelf-card.shelf-large {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.15);
}

.shelf-card.shelf-small {
    height: 95px;
    padding: 10px;
}

/* Central Floating Scanner FAB styles */
.mobile-scan-fab {
    background-color: #6366f1 !important; /* Brand indigo */
    border: 4px solid #09090b !important; /* bg-dark-200 equivalent */
}

.mobile-scan-fab:hover {
    background-color: #4f46e5 !important;
}

body.light-theme .mobile-scan-fab {
    background-color: #4f46e5 !important;
    border-color: #f1f5f9 !important; /* bg-dark-200 equivalent in light theme */
}

body.light-theme .mobile-scan-fab:hover {
    background-color: #4338ca !important;
}

/* ==========================================================================
   MOBILE VIEWPORT READ-ONLY RESTRICTIONS
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Hide all triggers for adding/editing items across any element tags */
    *[onclick*="openDeviceModal"],
    *[onclick*="openComponentModal"],
    *[onclick*="openCustomerModal"],
    *[onclick*="openSupplierModal"],
    *[onclick*="openUserModal"] {
        display: none !important;
    }
    
    /* Hide all triggers for using parts/components or disassembling */
    *[onclick*="quickUseComponentInRepair"],
    *[onclick*="quickUseComponentInCompatibility"],
    *[onclick*="handleNewRegistrationFromScan"] {
        display: none !important;
    }
    
    /* Hide all triggers for deleting items */
    *[onclick*="deleteDeviceConfirm"],
    *[onclick*="deleteComponentConfirm"],
    *[onclick*="deleteCustomerConfirm"],
    *[onclick*="deleteSupplierConfirm"],
    *[onclick*="deleteUserConfirm"] {
        display: none !important;
    }

    /* Hide any direct registration or write links */
    a[onclick*="openComponentModal"],
    a[onclick*="openDeviceModal"] {
        display: none !important;
    }
    
    /* Hide the "Smonta Componente" button inside device details */
    *[onclick*="setTimeout(() => openComponentModal"] {
        display: none !important;
    }

    /* Hide all triggers for printing, download label, print modal, and print actions on mobile */
    *[onclick*="printDirect"],
    *[onclick*="openPrintModal"],
    *[onclick*="downloadLabelPDF"],
    *[onclick*="triggerPDFPrint"],
    *[onclick*="startBatchPrinting"] {
        display: none !important;
    }
}

/* Regole per la stampa del report completo */
@media print {
    body > *:not(#print-section) {
        display: none !important;
    }
    #print-section {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white !important;
        color: black !important;
    }
    
    /* Stile elegante del report stampato */
    .print-report {
        font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
        color: #1f2937;
        line-height: 1.5;
        padding: 10px;
    }
    .print-report h1 {
        font-size: 22px;
        color: #111827;
        margin: 0 0 10px 0;
        font-weight: 700;
        border-bottom: 2px solid #3b82f6;
        padding-bottom: 8px;
    }
    .print-report h2 {
        font-size: 15px;
        color: #1f2937;
        margin: 25px 0 10px 0;
        font-weight: 600;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 5px;
        page-break-after: avoid;
        break-after: avoid;
    }
    .print-meta {
        display: flex;
        justify-content: space-between;
        font-size: 11px;
        color: #6b7280;
        margin-bottom: 20px;
        border-bottom: 1px dashed #e5e7eb;
        padding-bottom: 10px;
    }
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 10px;
        margin-bottom: 20px;
        font-size: 11px;
    }
    .print-table th {
        background-color: #f9fafb !important;
        color: #374151 !important;
        font-weight: 600;
        text-align: left;
        border-bottom: 2px solid #e5e7eb;
        padding: 8px 10px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .print-table td {
        border-bottom: 1px solid #f3f4f6;
        padding: 8px 10px;
        color: #4b5563;
    }
    .print-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    thead {
        display: table-header-group;
    }
    @page report-page {
        size: A4 portrait;
        margin: 1.5cm !important;
    }
    #print-section {
        page: report-page !important;
    }
}


