/* VELDEX INDUSTRIAL INTELLIGENCE - DESIGN SYSTEM */

:root {
    --bg: #0B0F14;
    --panel: #12171E;
    --panel2: #181E26;
    --line: rgba(0, 224, 255, 0.1);
    --text: #E2E8F0;
    --muted: #64748B;
    --accent: #00E0FF;
    --accent2: #FF8A00;
    --danger: #EF4444;
    --success: #10B981;
    
    --font-sans: 'Manrope', sans-serif;
    --font-display: 'Rajdhani', sans-serif;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --border-sm: 2px;
    --line-height-base: 1.6;
}

/* Base Body Styles */
html, body {
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: var(--line-height-base);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


/* SCROLLBARS */
.veldex-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 224, 255, 0.2) transparent;
}
.veldex-scroll::-webkit-scrollbar {
    width: 4px;
}
.veldex-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.veldex-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 224, 255, 0.2);
    border-radius: var(--border-sm);
}
.veldex-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 224, 255, 0.4);
}

/* ANIMATIONS */
@keyframes veldex-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}
@keyframes veldex-flicker {
    0%, 100% { filter: brightness(1); }
    33% { filter: brightness(1.1); }
    66% { filter: brightness(0.95); }
}
@keyframes veldex-scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}
@keyframes veldex-fade-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes veldex-sweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

.animate-veldex-pulse { animation: veldex-pulse 3s infinite ease-in-out; }
.animate-veldex-flicker { animation: veldex-flicker 4s infinite step-end; }

/* PANEL SYSTEM */
.veldex-panel {
    background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
    border: 1px solid var(--line);
    position: relative;
    transition: var(--transition);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.02);
    border-radius: var(--border-sm);
}
.veldex-panel:hover {
    border-color: rgba(0, 224, 255, 0.2);
    box-shadow: 0 0 30px rgba(0, 224, 255, 0.03), inset 0 1px 1px rgba(255, 255, 255, 0.03);
}
.veldex-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--accent);
    opacity: 0.3;
    box-shadow: 0 0 10px rgba(0, 224, 255, 0.2);
}

.scanline-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.03;
}
.scanline {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    animation: veldex-scanline 8s linear infinite;
}

/* INPUTS & SELECTS */
.veldex-input, .veldex-select {
    width: 100%;
    background: rgba(24, 30, 38, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1); /* Neutral border instead of cyan */
    border-radius: var(--border-sm);
    padding: 0.75rem 1rem;
    color: white;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
    outline: none !important;
    box-shadow: none;
}
.veldex-input:focus, .veldex-select:focus {
    border-color: rgba(0, 224, 255, 0.5); /* Subtler cyan focus */
    background: rgba(24, 30, 38, 0.9);
    box-shadow: none; /* Removed the strong glow */
    border-width: 1px;
}
.veldex-input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

/* BUTTONS */
.veldex-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--border-sm);
    font-family: var(--font-display);
    font-size: 13px; /* Increased from 12px */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: var(--transition);
    cursor: pointer;
}

.veldex-btn-primary {
    background: rgba(0, 224, 255, 0.1);
    border: 1px solid rgba(0, 224, 255, 0.3);
    color: var(--accent);
}
.veldex-btn-primary:hover:not(:disabled) {
    background: rgba(0, 224, 255, 0.2);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(0, 224, 255, 0.1);
}

.veldex-btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    color: var(--muted);
}
.veldex-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.veldex-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #F87171;
}
.veldex-btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
    border-color: #EF4444;
}

.veldex-btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
}
.veldex-btn-ghost:hover:not(:disabled) {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.veldex-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* BADGES */
.veldex-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem; /* Increased padding */
    border-radius: 1px;
    font-family: var(--font-display);
    font-size: 12px; /* Increased from 11px */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border: 1px solid transparent;
}

/* --- HEADER PROFILE --- */
.header-profile-block {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.header-profile-block:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(0, 224, 255, 0.2);
}

.header-user-info {
    text-align: right;
}

.header-username {
    color: var(--color-text);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-user-rank {
    color: var(--color-accent);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 2px;
    opacity: 0.9;
}

.header-corp-badge {
    background: linear-gradient(135deg, rgba(0, 224, 255, 0.1) 0%, rgba(0, 224, 255, 0.05) 100%);
    border: 1px solid rgba(0, 224, 255, 0.3);
    color: var(--color-accent);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(0, 224, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-corp-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--color-accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--color-accent);
}

.veldex-badge-corpo {
    background: rgba(0, 224, 255, 0.05);
    border-color: rgba(0, 224, 255, 0.2);
    color: var(--accent);
}

.veldex-badge-private {
    background: rgba(255, 138, 0, 0.05);
    border-color: rgba(255, 138, 0, 0.2);
    color: var(--accent2);
}

.veldex-badge-status {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: #34D399;
}

/* TABLES */
.veldex-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.veldex-table thead tr {
    border-bottom: 1px solid var(--line);
}
.veldex-table th {
    padding: 0.85rem 1rem;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #94A3B8;
}
.veldex-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 224, 255, 0.03);
    font-size: 15px;
    font-weight: 400;
    transition: var(--transition);
}
.veldex-table tbody tr {
    transition: var(--transition);
}
.veldex-table tbody tr:hover {
    background: rgba(0, 224, 255, 0.02);
}

.veldex-row {
    cursor: default;
}

/* STATUS DOTS */
.veldex-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.veldex-status-dot--ok {
    background: #00E0FF;
    box-shadow: 0 0 6px rgba(0, 224, 255, 0.8);
    animation: veldex-pulse-subtle 2s ease-in-out infinite;
}

.veldex-status-dot--error {
    background: #FF4D4D;
    box-shadow: 0 0 6px rgba(255, 77, 77, 0.8);
}

@keyframes veldex-pulse-subtle {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* TYPOGRAPHY */
.veldex-title-page {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: white;
}
.veldex-subtitle-page {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* LAYOUT SCOPES */
/* --- LAYOUT STRUCTURE --- */
#sidebar-container {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 240px;
    z-index: 50;
    overflow-y: visible;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.veldex-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 18px 18px 22px;
  background: transparent;
}

.veldex-sidebar-logo {
  display: block;
  width: 140px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  background: transparent;
}

@media (max-width: 768px) {
  .veldex-sidebar-brand {
    padding: 14px 16px;
  }

  .veldex-sidebar-logo {
    width: 120px;
  }
}

.main-content {
    margin-left: 240px;
    width: calc(100% - 240px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.view-section {
    width: 100%;
    padding: 1.5rem; /* 24px gap from sidebar */
}

/* DASHBOARD SPECIFIC SCROLLS */
.results-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.results-container thead {
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 20;
    box-shadow: 0 1px 0 var(--line);
}

body.is-dashboard {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
}

body.is-dashboard .main-content {
    height: auto;
    min-height: 100vh;
    overflow: visible;
}

body.is-dashboard #view-dashboard {
    height: auto;
    min-height: calc(100vh - 84px);
    overflow: visible;
}

/* Tablet/Desktop overrides to restore fixed layout if desired */
@media (min-width: 1025px) {
    body.is-dashboard {
        height: 100vh;
        overflow: hidden;
    }
    body.is-dashboard .main-content {
        height: 100vh;
        overflow: hidden;
    }
    body.is-dashboard #view-dashboard {
        height: calc(100vh - 84px);
        overflow: hidden;
    }
}


@media (max-width: 1024px) {
    #sidebar-container {
        display: none; /* Mobile menu handled by navbar.js */
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .view-section {
        padding: 1rem;
        padding-bottom: 5rem; /* Space for footer/bottom of page */
    }
    
    /* Ensure panels stack nicely and take full width */
    .veldex-panel {
        width: 100%;
        margin-bottom: 1rem;
    }

    /* Table responsiveness wrapper */
    .results-container, .overflow-x-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent text overflow in small cells */
    .veldex-table th, .veldex-table td {
        white-space: nowrap;
        padding: 0.75rem 0.5rem;
    }
}


/* --- INVENTORY & OCR READABILITY SCOPES --- */
#view-inventory .veldex-input,
#view-inventory .veldex-select,
#ocr-section .veldex-input,
#ocr-section .veldex-select {
    font-size: 16px;
    padding: 0.875rem 1.25rem;
}

#view-inventory .veldex-btn,
#ocr-section .veldex-btn {
    font-size: 14px;
    padding: 0.75rem 1.5rem;
}

#view-inventory label,
#ocr-section label {
    font-size: 13px !important;
    letter-spacing: 0.05em;
}

.ocr-mat-row {
    transition: var(--transition);
}

.ocr-mat-row:hover {
    background: rgba(0, 224, 255, 0.05);
}
/* --- MOBILE OPTIMIZATIONS (768px) --- */
@media (max-width: 768px) {
    /* Global Layout */
    .view-section {
        padding: 0.75rem;
        padding-bottom: 4rem;
    }

    /* Typography */
    .text-4xl { font-size: 1.75rem !important; }
    .text-3xl { font-size: 1.5rem !important; }
    .text-2xl { font-size: 1.25rem !important; }
    
    .veldex-title-page {
        font-size: 1.25rem;
        letter-spacing: 0.15em;
    }

    /* Panels & Cards */
    .veldex-panel {
        padding: 1rem !important;
        margin-bottom: 0.75rem;
    }

    /* Buttons */
    .veldex-btn {
        width: 100% !important;
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 14px;
    }

    /* Inputs & Selects */
    .veldex-input, .veldex-select {
        width: 100% !important;
        height: 44px;
        padding: 0.6rem 1rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Grids & Spacing */
    .grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .space-y-8 > * + * { margin-top: 1.5rem !important; }
    .space-y-6 > * + * { margin-top: 1rem !important; }
    .gap-8 { gap: 1rem !important; }
    .gap-6 { gap: 0.75rem !important; }

    /* Form specific */
    label {
        font-size: 11px !important;
        margin-bottom: 4px !important;
    }

    /* Table Adjustments */
    .veldex-table th, .veldex-table td {
        font-size: 13px;
        padding: 0.6rem 0.5rem;
    }

    /* Inventory Items List */
    #uex-items-list li {
        padding: 0.75rem !important;
    }
}
/* --- UX IMPROVEMENTS: STICKY ACTIONS & TOASTS --- */

/* Button Interaction Feedback */
button {
    transition: transform 0.1s ease, filter 0.2s ease !important;
}

button:active:not(:disabled) {
    transform: scale(0.97) !important;
}

button:hover:not(:disabled) {
    filter: brightness(1.1);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #101820;
    color: var(--accent);
    padding: 12px 20px;
    border-radius: 6px;
    border: 1px solid var(--line);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 14px;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 224, 255, 0.1);
    pointer-events: none;
    white-space: nowrap;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-error {
    color: var(--danger) !important;
    border-color: rgba(239, 68, 68, 0.3);
}

.toast-success {
    color: var(--success) !important;
    border-color: rgba(16, 185, 129, 0.3);
}

/* Sticky Action Wrapper (Mobile Only) */
@media (max-width: 768px) {
    .view-section {
        padding-bottom: 120px !important; /* Extra padding for sticky button */
    }

    .container-action-mobile {
        position: sticky;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(11, 15, 20, 0.98);
        backdrop-blur: 12px;
        padding: 12px;
        border-top: 1px solid var(--line);
        z-index: 100; /* Lower than dropdowns */
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .container-action-mobile.is-hidden {
        transform: translateY(100%);
        opacity: 0;
        pointer-events: none;
    }

    .container-action-mobile .veldex-btn {
        width: 100% !important;
        height: 48px;
    }

    /* Dropdowns must be above sticky bar */
    #location-autocomplete-list, 
    #ocr-location-list,
    .autocomplete-dropdown {
        z-index: 300 !important;
    }
}

/* Autocomplete UX Fixes */
.autocomplete-dropdown {
    max-height: 200px !important; /* ≈ 5 items visibles */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--panel) !important;
    border: 1px solid var(--line) !important;
    border-radius: 2px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    scroll-behavior: smooth;
}

.autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 224, 255, 0.2);
    border-radius: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 224, 255, 0.4);
}

.autocomplete-item,
.ocr-loc-item {
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 12px !important;
    transition: all 0.2s ease;
    cursor: pointer;
    border-bottom: 1px solid var(--line);
}

.autocomplete-item:last-child,
.ocr-loc-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.ocr-loc-item:hover {
    background: rgba(0, 224, 255, 0.1) !important;
    padding-left: 1.5rem !important;
}

