/* =========================================
   GLOBAL VARIABLES & 1080P SCALING
========================================= */
:root {
    --pico-background-color: #050508;
    --pico-card-background-color: #0d0e14;
    --pico-color: #f1f5f9;
    --pico-muted-color: #64748b;
    --pico-border-color: #1e293b;
    --pico-primary: #38bdf8;
    --pico-primary-background: #0284c7;
    --pico-primary-hover: #0369a1;
    --pico-form-element-background-color: #0a0b10;
    --pico-form-element-border-color: #1e293b;
    --pico-border-radius: 12px;
}

/* 1080p Scale Down - Shrinks Pico's base sizing universally by ~12.5% */
html {
    font-size: 14px !important; 
}

/* =========================================
   BASE LAYOUT & PANELS
========================================= */
body {
    background-color: var(--pico-background-color);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.07) 0%, transparent 60%),
        radial-gradient(circle at 100% 100%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
    min-height: 100vh;
    display: flex;
    align-items: flex-start; /* Portals sit near the top */
    justify-content: center;
    padding: 1rem; /* 1080p: Reduced from 2rem */
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 1080p: Limits max width so it doesn't stretch too far on 4K, but fits 1080p */
main { 
    width: 96vw; 
    max-width: 1600px; 
}

/* Universal Glass Panels */
.glass-panel, .intake-card {
    background: rgba(13, 14, 20, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.9),
        0 0 30px 0 rgba(56, 189, 248, 0.04);
    border-radius: 18px;
    padding: 1.5rem 2rem; /* 1080p: Reduced padding */
}

/* Intake-Specific Layout */
.intake-card {
    align-self: center; /* Intake sits vertically centered */
    max-width: 640px;
    width: 100%;
}
.login-panel { 
    max-width: 500px; 
    margin: 10vh auto; 
}

/* =========================================
   TYPOGRAPHY & UTILITIES
========================================= */
.hidden { display: none !important; }

h2, .brand-header h1 { 
    font-weight: 800; 
    letter-spacing: -0.025em; 
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
}

/* Dashboard Headers & Toolbars (1080p Condensed) */
.dashboard-header { 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 1px solid var(--pico-border-color); 
    padding-bottom: 1rem; margin-bottom: 1rem; 
}
.nav-tabs { 
    display: flex; justify-content: flex-start; gap: 1rem; margin-bottom: 1rem; 
}
.nav-tabs a { 
    color: var(--pico-muted-color); text-decoration: none; 
    font-weight: 600; padding-bottom: 0.5rem; transition: color 0.2s; 
}
.nav-tabs a.active { color: var(--pico-primary); border-bottom: 2px solid var(--pico-primary); }
.nav-tabs a:hover:not(.active) { color: var(--pico-color); }

.toolbar { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 0.5rem; gap: 1rem; 
}

/* Intake Header & Badges */
.brand-header { text-align: center; margin-bottom: 2rem; }
.brand-header p { color: var(--pico-muted-color); font-size: 0.9rem; margin: 0; }
.badge {
    display: inline-block; padding: 0.25rem 0.75rem; font-size: 0.7rem; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase; color: #38bdf8;
    background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 9999px; margin-bottom: 0.75rem;
}

/* =========================================
   FORMS & INPUTS
========================================= */
input:focus, select:focus, textarea:focus { 
    border-color: #38bdf8 !important; 
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18) !important; 
    outline: none !important;
}
select option { background-color: var(--pico-background-color); color: var(--pico-color); }

.search-input { width: 100%; max-width: 400px; background: rgba(255, 255, 255, 0.02) !important; margin-bottom: 0; border-radius: 8px; }

/* Intake Form specifics */
.grid-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 576px) { .grid-fields { grid-template-columns: 1fr; } }
.field-group { margin-bottom: 1rem; }
.field-full { grid-column: 1 / -1; }

.intake-card label {
    font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em;
    text-transform: uppercase; color: #cbd5e1; margin-bottom: 0.4rem;
}
.intake-card input, .intake-card textarea {
    background-color: var(--pico-form-element-background-color) !important;
    border: 1px solid var(--pico-form-element-border-color) !important;
    color: var(--pico-color) !important; border-radius: 10px !important;
    padding: 0.75rem 1rem !important; font-size: 0.95rem !important; margin-bottom: 0 !important;
}
.intake-card textarea { resize: vertical; min-height: 120px; }

/* Buttons */
button.secondary { 
    background: rgba(255, 255, 255, 0.05) !important; 
    border: 1px solid rgba(0, 0, 255, 0.7) !important; 
    color: #cbd5e1 !important; transition: all 0.2s ease; 
}
button.secondary:hover { background: rgba(255, 255, 255, 0.1) !important; }

.intake-card button[type="submit"] {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff; font-weight: 700; font-size: 0.95rem; letter-spacing: 0.025em;
    padding: 0.85rem 1.5rem; border-radius: 10px; transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.35); margin-top: 1rem; width: 100%;
}
.intake-card button[type="submit"]:hover {
    transform: translateY(-1px); box-shadow: 0 6px 22px rgba(2, 132, 199, 0.55);
}

/* =========================================
   TABLES (High Density for 1080p)
========================================= */
table.ticket-table, table.user-table { 
    table-layout: fixed; width: 100%; margin-bottom: 0; border-collapse: collapse; 
}
table.ticket-table th, table.user-table th { 
    color: var(--pico-muted-color); font-weight: 600; font-size: 0.85rem; 
    text-transform: uppercase; letter-spacing: 0.05em; 
    border-bottom: 1px solid var(--pico-border-color); 
    padding: 0.5rem 0.5rem; /* 1080p Tweak */
    user-select: none; text-align: left;
}
table.ticket-table td, table.user-table td { 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.02); 
    padding: 0.5rem 0.5rem; /* 1080p Tweak */
    color: var(--pico-color); font-size: 0.9rem; /* 1080p Tweak */
}

/* Specific Column Widths */
table.ticket-table th:nth-child(1) { width: 80px; }  
table.ticket-table td:nth-child(1) { overflow: visible; text-overflow: clip; }
table.ticket-table th:nth-child(2) { width: 14%; } /* Submitter */
table.ticket-table th:nth-child(3) { width: 10%; } /* Location */
table.ticket-table th:nth-child(4) { width: 20%; } /* Brief */
table.ticket-table th:nth-child(5) { width: 22%; } /* Description */
table.ticket-table th:nth-child(6) { width: 8%; } /* Assigned */
table.ticket-table th:nth-child(7) { width: 12%; text-align: center; } /* Presence */
table.ticket-table th:nth-child(8) { width: 7%; text-align: center; } /* Status */
table.ticket-table th:nth-child(9) { width: 7%; text-align: right; }  /* NEW: Date/Time */

table.user-table th:nth-child(1) { width: 15%; }
table.user-table th:nth-child(2) { width: 15%; }
table.user-table th:nth-child(3) { width: 25%; }
table.user-table th:nth-child(4) { width: 15%; text-align: center; }
table.user-table th:nth-child(4) { width: 15%; text-align: center; }
table.user-table th:nth-child(4) { width: 15%; text-align: center; }

/* Table Interactivity */
.clickable-row { cursor: pointer; transition: background-color 0.15s ease; }
.clickable-row:hover td { background-color: rgba(255, 255, 255, 0.02); }

table.ticket-table th.sortable { cursor: pointer; transition: color 0.2s; }
table.ticket-table th.sortable:hover { color: var(--pico-primary); }
.sort-icon { display: inline-block; width: 12px; margin-left: 4px; color: var(--pico-primary); font-size: 0.75rem; }

.ticket-unread td { background-color: rgba(56, 189, 248, 0.03); color: #fff !important; }
.ticket-unread td:first-child { box-shadow: inset 3px 0 0 0 var(--pico-primary); }

/* Status & Role Markers */
mark { padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; background: rgba(255, 255, 255, 0.1); }
mark.status-open, mark.role-owner { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2); }
mark.status-in_progress, mark.role-manager { background: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.2); }
mark.status-resolved, mark.role-technician { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.2); }
mark.status-closed, mark.role-user { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.2); }

/* =========================================
   MODALS, DIALOGS, & HOVER PREVIEWS
========================================= */
dialog article { 
    background: rgba(13, 14, 20, 0.95) !important; 
    backdrop-filter: blur(24px); 
    border: 1px solid rgba(255, 255, 255, 0.08); 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9), 0 0 30px 0 rgba(56, 189, 248, 0.04); 
    border-radius: 18px; max-width: 1200px; width: 90vw; overflow-x: hidden; 
}
#userModal article { max-width: 650px; width: 100%; }

.modal-body { max-height: 70vh; overflow-y: auto; padding-right: 0.5rem; overflow-x: hidden; }

/* 1080p: Split-Modal Layout Fixes */
dialog#ticketModal article {
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
dialog#ticketModal.modal-split article {
    max-width: 2200px !important;
    width: 98vw !important;
}
/* Replaces the hardcoded inline widths on your split panes */
#ticketDetailsContainer { flex: 1; min-width: 50% !important; }
#kbSidePanel { width: 40% !important; max-width: 600px !important; }


#hoverPreview { 
    position: fixed; z-index: 9999; pointer-events: none; 
    background: rgba(13, 14, 20, 0.98); padding: 0.5rem; 
    border: 1px solid var(--pico-border-color); border-radius: 12px; 
    box-shadow: 0 15px 35px rgba(0,0,0,0.8); transform: translate(15px, 15px); 
}
#hoverPreview img { max-width: 250px; max-height: 250px; object-fit: contain; display: block; border-radius: 6px; }

/* =========================================
   COMPONENTS & WIDGETS
========================================= */
/* Notes */
.note-bubble { background: rgba(255, 255, 255, 0.03); border-left: 3px solid var(--pico-primary); padding: 0.75rem 1rem; margin-bottom: 0.75rem; border-radius: 0 6px 6px 0; }
.note-bubble.role-technician, .note-bubble.role-owner { border-left-color: #facc15; }
.note-bubble.role-manager { border-left-color: #34d399; }
.note-bubble.role-user { border-left-color: var(--pico-primary); }

/* Settings / Setup */
.settings-card { background: rgba(255, 255, 255, 0.02); border: 1px solid var(--pico-border-color); border-radius: 12px; padding: 1.5rem; }

/* Badges / Items */
.presence-badge { display: inline-flex; align-items: center; gap: 0.5rem; margin-left: 1.5rem; padding: 0.3rem 0.8rem; background: rgba(234, 179, 8, 0.15); border: 1px solid rgba(234, 179, 8, 0.3); color: #facc15; border-radius: 20px; font-size: 0.8rem; font-weight: 600; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 0.8; } 50% { opacity: 1; } 100% { opacity: 0.8; } }

.manager-badge { display: inline-block; background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 700; margin-right: 0.5rem; letter-spacing: 0.05em; }

.subordinate-item { display: flex; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.subordinate-item:last-child { border-bottom: none; }
.subordinate-item input[type="checkbox"] { margin-bottom: 0; margin-right: 0.75rem; }

.kb-item { border: 1px solid rgba(255,255,255,0.05); background: rgba(255,255,255,0.02); border-radius: 8px; padding: 1rem 1.5rem; margin-bottom: 1rem; }

/* Alerts */
.alert { padding: 0.85rem 1rem; border-radius: 10px; margin-bottom: 1.5rem; font-size: 0.875rem; font-weight: 500; display: flex; align-items: center; gap: 0.5rem; }
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: #f87171; }

/* =========================================
   QUILL EDITOR OVERRIDES (Dark Mode)
========================================= */
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--pico-border-color) !important; border-radius: 4px; margin-bottom: 0.5rem; }
.ql-toolbar.ql-snow .ql-picker, .ql-toolbar.ql-snow .ql-stroke { stroke: #cbd5e1 !important; color: #cbd5e1 !important; }
.ql-toolbar.ql-snow .ql-fill { fill: #cbd5e1 !important; }
.ql-toolbar.ql-snow .ql-picker-options { background-color: var(--pico-form-element-background-color) !important; border-color: var(--pico-border-color) !important; }
.ql-editor { font-family: inherit; font-size: 1rem; color: #f1f5f9; min-height: 300px; }
.ql-editor img { max-width: 100%; border-radius: 6px; margin: 1rem 0; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
.ql-toolbar.ql-snow .ql-picker-label { background-color: transparent !important; border: none !important; padding: 0 8px !important; box-shadow: none !important; display: flex !important; align-items: center !important; }
.ql-toolbar.ql-snow .ql-picker-item { color: #cbd5e1 !important; padding-bottom: 5px !important; }
.ql-toolbar.ql-snow .ql-picker-item:hover, .ql-toolbar.ql-snow .ql-picker-label:hover { color: var(--pico-primary) !important; }

/* ======================================
   FOR DEMO USE ONLY (login cards)
=======================================*/
.demo-card {
        background: rgba(56, 189, 248, 0.1);
        border: 1px solid rgba(56, 189, 248, 0.3);
        border-radius: 8px;
        padding: 0.5rem;
        text-align: center;
        cursor: pointer;
        color: #38bdf8;
        font-size: 0.85rem;
        transition: all 0.2s;
    }
.demo-card:hover:not(.in-use) { background: rgba(56, 189, 248, 0.2); transform: translateY(-2px); }
.demo-card.in-use {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--pico-muted-color);
    cursor: not-allowed;
    opacity: 0.6;
}