:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --danger-color: #ef4444;
    --danger-color: #ef4444;
    --success-color: #10b981;
}

/* THEME 1: PXS CI Hell (Default / Yellow) */
body.theme-default {
    --bg-color: #f5f7fa;
    --panel-bg: #ffffff;
    --panel-border: #e2e8f0;
    --primary-color: #FFDE00;
    --primary-hover: #eab308;
    --text-color: #334155;
    --text-muted: #64748b;
    background-image: none;
}
body.theme-default .glass-panel, body.theme-default .glass-header {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* THEME 3: PXS Website (Dark / Yellow Accent) */
body.theme-website {
    --bg-color: #0A0D14;
    --panel-bg: #1A202C;
    --panel-border: #242b3b;
    --primary-color: #FFDE00;
    --primary-hover: #eab308;
    --text-color: #E2E8F0;
    --text-muted: #94A3B8;
    background-image: none;
}
body.theme-website .glass-panel, body.theme-website .glass-header {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* THEME 4: Future Mode (Experimental Holographic) */
body.theme-future {
    --bg-color: #020005;
    --panel-bg: rgba(25, 0, 50, 0.3);
    --panel-border: rgba(255, 0, 255, 0.3);
    --primary-color: rgba(255, 0, 255, 0.8);
    --primary-hover: #ff00ff;
    --text-color: #00ffff;
    --text-muted: rgba(0, 255, 255, 0.6);
    background-image: none;
}
body.theme-future .glass-panel, body.theme-future .glass-header {
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.5), inset 0 0 10px rgba(0, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

@font-face {
    font-family: 'Researcher';
    src: url('fonts/researcher.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.15), transparent 25%);
}

.hidden {
    display: none !important;
}

#app {
    width: 100%;
    max-width: 1400px; /* Increased to accommodate sidebar */
    padding: 2rem 2rem 2rem 2rem;
    height: 100vh; /* Make app fill height */
    overflow: hidden; /* Prevent body scroll, handle scroll internally */
}

/* Glassmorphism Panels */
.glass-panel,
.glass-header {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem 2rem;
}

.top-header {
    margin-bottom: 0;
    border-radius: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1,
h2,
h3 {
    font-weight: 700;
}

.logo-text {
    font-family: 'Researcher', 'Inter', sans-serif;
    font-weight: 700;
}

/* Tabs */
.glass-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: var(--panel-bg);
    border-radius: 12px;
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.glass-tabs.hidden {
    display: none !important;
}

.tab-content {
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Forms & Inputs */
.input-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

input[readonly] {
    color: var(--primary-color);
    background: rgba(15, 23, 42, 0.3);
    border-style: dashed;
}

select.glass-select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

input.datalist-input {
    background: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 1rem center / 1em, rgba(15, 23, 42, 0.6) !important;
    padding-right: 2.5rem; /* Make room for the arrow */
    cursor: pointer;
}
input.datalist-input::-webkit-calendar-picker-indicator {
    opacity: 0; /* Hide default native dropdown arrow */
    width: 100%; /* Make the clickable area cover the arrow */
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
}

select.glass-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

select.glass-select option {
    background: var(--bg-color);
    color: var(--text-color);
}

/* Buttons */
button {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--panel-border);
}

.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Badges */
.badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Error Messages */
.error-msg {
    color: var(--danger-color);
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

/* Login Screen specific */
#login-screen {
    max-width: 400px;
    margin: 0 auto;
}

#login-screen h2 {
    text-align: center;
    margin-bottom: 2rem;
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    height: calc(100vh - 4rem);
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    height: 100%;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding-left: 0.5rem;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.sidebar-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-align: left;
    transition: all 0.2s;
    width: 100%;
}

.sidebar-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-btn.active {
    background: var(--primary-color);
    color: white;
}

.main-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.main-content > .glass-header {
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    /* Custom scrollbar offsets */
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.horizontal-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.horizontal-form-grid .input-group {
    margin-bottom: 0;
}

.horizontal-form-grid .full-width {
    grid-column: 1 / -1;
}

.horizontal-form-grid .conditional-wrapper {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Dashboard Widget Grid */
.dashboard-widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.dashboard-widget {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s, border-color 0.6s ease-out;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.dashboard-widget:active {
    cursor: grabbing;
}

.dashboard-widget:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    background: rgba(30, 41, 59, 0.85);
    border-color: var(--primary-color);
}

.dashboard-widget.dragging {
    opacity: 0.5;
    background: rgba(59, 130, 246, 0.1);
}

.dashboard-widget.drag-over {
    border: 2px dashed var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
    /* Fade IN immediately when hovering, Fade OUT slowly only when leaving */
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s, border-color 60s ease-out;
}

.widget-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.dashboard-widget h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: var(--text-color);
}

.dashboard-widget p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border: 1px solid var(--panel-border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(21px);
  background-color: white;
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Table */
.table-container {
    overflow-x: auto;
    margin-top: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 1rem;
    border-bottom: 1px solid var(--panel-border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td a {
    color: var(--primary-color);
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

/* Section styling */
.create-order-section h2,
.active-orders-section h2 {
    margin-bottom: 1.5rem;
}

#latest-link-result {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--panel-border);
}

#latest-link-result h3 {
    color: var(--success-color);
    margin-bottom: 1rem;
}

/* PXS Custom Modal Alerts */
.pxs-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    padding: 2rem 1rem;
    overflow-y: auto;
}

.pxs-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.pxs-modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    margin: auto; /* This centers it in the flex container without clipping */
    max-width: 400px;
    text-align: center;
    color: var(--text-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.pxs-modal-overlay.active .pxs-modal-content {
    transform: translateY(0) scale(1);
}

.pxs-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.pxs-modal-body {
    font-size: 1rem;
    margin-bottom: 24px;
    color: var(--text-color);
}

.pxs-modal-btn {
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.pxs-modal-btn:hover {
    opacity: 0.9;
}

/* Future Mode Toggle Slider */
.future-mode-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color);
    font-weight: 600;
}

.future-mode-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    transition: .4s;
    margin-right: 8px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: linear-gradient(45deg, #ff00cc, #3333ff);
    box-shadow: 0 0 10px rgba(255,0,204,0.6);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.toggle-label {
    user-select: none;
}

/* =========================================================================
   CUSTOMER PORTAL WIDGETS (Restored KPI & Dashboard panels)
   ========================================================================= */

.view-header {
    margin-bottom: 2rem;
}
.view-header h2 {
    font-size: 1.8rem;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}
.view-header p {
    color: var(--text-muted);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}
.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}
.kpi-icon .material-icons {
    font-size: 32px;
}
.kpi-data h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-heading);
}

.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.widget-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}
.panel-title {
    font-size: 1.2rem;
    color: var(--text-heading);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 2rem 0;
}