html {
    height: 100%;
}

body {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: block;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    font-size: 14px;
}

/* Main app content */
#mainApp {
    padding: 0 !important;
    margin: 0 !important;
    display: block;
    width: 100%;
}

/* Footer - hidden for now */
footer {
    width: 100%;
    position: relative;
    display: none;
}

/* Desktop mode - ensure product images are clickable with hover effects */
@media (min-width: 768px) {
    #productImage,
    #stockOutProductImage,
    #shelfingProductImage {
        cursor: pointer !important;
        pointer-events: auto !important;
    }

    #productImage:hover,
    #stockOutProductImage:hover,
    #shelfingProductImage:hover {
        opacity: 0.9;
        transform: scale(1.05);
        transition: all 0.2s ease;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
}

/* Ensure all text elements are copyable */
*, *::before, *::after {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

/* Prevent text selection from being cleared */
::selection {
    background-color: #3b82f6 !important;
    color: white !important;
}

::-moz-selection {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* Except buttons and interactive elements */
button, .btn, [role="button"] {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Module navigation styles */
.module-tab.active {
    background: rgba(255, 255, 255, 0.2) !important;
    opacity: 1 !important;
}

/* Module sections - hidden by default, shown when active */
.module-section {
    display: none;
    padding: 0 !important;
    margin: 0 !important;
}

.module-section.active {
    display: block;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    height: auto !important;
}

.selectable-text {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

button {
    user-select: none;
    -webkit-user-select: none;
}

input, select, textarea {
    user-select: auto;
    -webkit-user-select: auto;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Ensure header allows dropdown to overflow */
.header-container {
    overflow: visible !important;
    position: relative;
    z-index: 1;
}

/* Z-index hierarchy */
.z-dropdown { z-index: 1000; }
.z-modal { z-index: 5000; }
.z-toast { z-index: 8000; }
.z-user-menu { z-index: 10000; }
.z-page-selector { z-index: 15000; }

/* Ensure dropdowns are above everything */
#pageSelectorDropdown {
    z-index: 15000 !important;
    position: absolute !important;
    background: white !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

/* Ensure dropdown parent has proper stacking context */
#pageSelectorButton {
    position: relative;
}

/* Ensure container allows dropdown to be visible */
.container {
    overflow: visible !important;
}

/* Ensure main content doesn't interfere with dropdowns */
.glass-effect {
    position: relative;
}

/* Fix any other stacking context issues */
.main-content {
    position: relative;
    z-index: 0;
}

/* New dropdown styling outside container */
#userDropdown {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 999999;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 192px;
    display: none;
}

#userDropdown.show {
    display: block !important;
}

/* Ensure button is clickable */
#userMenuButton {
    position: relative;
    z-index: 999998;
    cursor: pointer;
}

.scan-button {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
    transform: scale(1);
    transition: all 0.3s ease;
}

.scan-button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 25px rgba(255, 107, 107, 0.4);
}

.inventory-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.compact-card {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.inventory-item {
    transition: all 0.2s ease;
    border-radius: 8px;
    position: relative;
}

.inventory-item:hover {
    background: rgba(59, 130, 246, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-in;
}

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

.inventory-blink {
    animation: inventoryBlink 2s infinite;
}

@keyframes inventoryBlink {
    0%, 50% {
        background-color: #fef3c7;
        border-color: #f59e0b;
        transform: scale(1);
    }
    25% {
        background-color: #fbbf24;
        border-color: #d97706;
        transform: scale(1.02);
    }
}

.stat-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(37, 99, 235, 0.05) 100%);
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.order-system-row {
    transition: all 0.2s ease;
}

.order-system-row:hover {
    background-color: rgba(243, 244, 246, 0.5);
}

.order-system-row.selected {
    background-color: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.inline-form {
    background: rgba(254, 243, 199, 0.9);
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 16px;
    margin-top: 0;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.quantity-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 8px;
}

.quantity-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #2563eb;
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 8px;
}

.product-details-container {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 15px;
    min-height: 252px;
    display: flex;
    flex-direction: column;
}

.product-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.product-details-header h2 {
    color: #1f2937;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.remove-btn {
    background: #ef4444;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.remove-btn:hover {
    background: #dc2626;
}

.product-content-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    flex: 1;
}

.product-image-box {
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    width: 160px;
}

.product-image-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.product-details-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.product-title {
    font-size: 17px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.3;
    margin-bottom: 8px;
}

.product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.badge-electronics {
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.badge-supplier {
    background: #8b5cf6;
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.product-info-compact {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.info-item-compact {
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 6px 4px;
}

.info-label-compact {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 2px;
}

.info-label-compact i {
    color: #9ca3af;
    margin-right: 4px;
    font-size: 10px;
}

.info-value-compact {
    font-size: 13px;
    color: #374151;
    font-family: inherit;
    background: transparent;
    padding: 2px 0px;
    border-radius: 0px;
    word-break: break-all;
    font-weight: 400;
}

.status-badge-compact {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-in-stock {
    background: #dcfce7;
    color: #166534;
}

.status-out-stock {
    background: #fecaca;
    color: #991b1b;
}

.status-dot-compact {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot-green {
    background: #22c55e;
}

.status-dot-red {
    background: #ef4444;
}

.user-avatar {
    transition: all 0.2s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
}

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

@media (max-width: 1024px) {
    .product-content-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .product-image-box {
        width: 140px;
        height: 140px;
        margin: 0 auto;
    }

    .product-info-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    #userInfo {
        display: none;
    }

    #mobileUserInfo {
        display: block;
    }
}

@media (max-width: 768px) {
    .product-details-container {
        padding: 6px;
        min-height: auto;
    }

    .product-details-header {
        margin-bottom: 6px;
    }

    .product-content-grid {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 6px;
    }

    .product-details-header h2 {
        font-size: 12px;
        margin: 0;
    }

    .product-title {
        font-size: 12px;
        margin: 0;
        line-height: 1.2;
        font-weight: 600;
    }

    .product-image-box {
        width: 55px;
        height: 55px;
        flex-shrink: 0;
    }

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

    .product-info-compact {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 3px 6px;
        margin-top: 6px;
    }

    .info-item-compact {
        padding: 3px;
        font-size: 0.55rem;
        border-radius: 3px;
        background: rgba(255, 255, 255, 0.1);
    }

    .info-label-compact {
        font-size: 0.5rem;
        margin-bottom: 1px;
        display: flex;
        align-items: center;
        gap: 2px;
    }

    .info-label-compact i {
        font-size: 0.45rem;
    }

    .info-value-compact {
        font-size: 0.55rem;
        font-weight: 600;
        line-height: 1.1;
    }

    .glass-effect {
        padding: 6px;
    }

    .metric-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 6px;
    }
}

/* Responsive visibility classes */
.desktop-only-cards {
    display: none !important;
}

.mobile-only-text {
    display: block !important;
}

@media (min-width: 768px) {
    .desktop-only-cards {
        display: grid !important;
    }

    .mobile-only-text {
        display: none !important;
    }
}

.mobile-table {
    font-size: 0.75rem;
}

@media (max-width: 640px) {
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .mobile-table th,
    .mobile-table td {
        padding: 0.25rem 0.125rem;
        font-size: 0.625rem;
    }

    .mobile-table .truncate-mobile {
        max-width: 50px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem;
    }

    .inventory-item {
        padding: 0.375rem;
    }

    .mobile-compact {
        font-size: 0.625rem;
        padding: 0.375rem;
    }

    .glass-effect {
        padding: 0.75rem;
    }

    .module-tab {
        padding: 0.375rem 0.5rem;
        font-size: 0.625rem;
    }

    button {
        padding: 0.375rem 0.75rem;
        font-size: 0.625rem;
    }

    input, select {
        padding: 0.375rem;
        font-size: 0.625rem;
    }
}