/* Modern CSS for Bonneville Informatics */

/* ==========================================================================
   Theme System - Light/Dark with auto-detection
   ========================================================================== */

/* Base variables (shared between themes) */
:root {
    --color-primary: #5a5f5a;       /* Neutral grey with subtle warmth */
    --color-primary-dark: #484c48;
    --color-primary-light: #3d9e9e; /* Teal from wavy line */
    --color-accent: #b33030;        /* Crimson from mountain */
    --color-accent-dark: #8c2424;
    --color-gold: #c9b95c;          /* Gold from chip pins */
    --max-width: 1200px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --border-radius: 6px;
    --transition: 0.2s ease;

    /* Light theme colors (default) */
    --color-bg: #f8f9f8;
    --color-bg-alt: #eef0ee;
    --color-text: #333;
    --color-text-light: #666;
    --color-white: #fff;
    --color-border: #d4ddd4;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);

    /* Additional theme-aware colors */
    --color-surface: #fff;
    --color-surface-hover: #f5f5f5;
    --color-input-bg: #fff;
    --color-table-row-alt: #f8f9f8;
    --color-modal-overlay: rgba(0,0,0,0.5);

    /* Semantic colors */
    --color-success: #22c55e;
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-warning: #f59e0b;
    --color-warning-bg: #fef9c3;
    --color-warning-text: #854d0e;
    --color-danger: #ef4444;
    --color-danger-bg: #fee2e2;
    --color-danger-text: #991b1b;
    --color-info: #0066cc;
    --color-info-bg: #e8f4f4;
    --color-info-text: #1e40af;

    /* Status colors */
    --color-status-open: #0066cc;
    --color-status-in-progress: #cc9900;
    --color-status-waiting: #cc6600;
    --color-status-resolved: #009900;
    --color-status-closed: #666;

    /* Text muted */
    --color-text-muted: #666;
}

/* Dark theme - auto-detected via prefers-color-scheme */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #1a1a1a;
        --color-bg-alt: #252525;
        --color-text: #e4e4e4;
        --color-text-light: #a0a0a0;
        --color-white: #1e1e1e;
        --color-border: #3a3a3a;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
        --color-surface: #252525;
        --color-surface-hover: #2d2d2d;
        --color-input-bg: #2a2a2a;
        --color-table-row-alt: #222;
        --color-modal-overlay: rgba(0,0,0,0.7);
        --color-primary: #7a7f7a;
        --color-primary-light: #4db8b8;

        /* Dark mode semantic colors */
        --color-success: #4ade80;
        --color-success-bg: #14532d;
        --color-success-text: #86efac;
        --color-warning: #fbbf24;
        --color-warning-bg: #451a03;
        --color-warning-text: #fde68a;
        --color-danger: #f87171;
        --color-danger-bg: #450a0a;
        --color-danger-text: #fca5a5;
        --color-info: #60a5fa;
        --color-info-bg: #1e3a5f;
        --color-info-text: #93c5fd;

        /* Dark mode status colors */
        --color-status-open: #60a5fa;
        --color-status-in-progress: #fbbf24;
        --color-status-waiting: #fb923c;
        --color-status-resolved: #4ade80;
        --color-status-closed: #9ca3af;

        --color-text-muted: #9ca3af;
    }

    /* Logo backdrop for visibility in dark mode */
    #header img {
        background: rgba(255, 255, 255, 0.85);
        padding: var(--spacing-sm);
        border-radius: var(--border-radius);
    }
}

/* Dark theme - manual override */
[data-theme="dark"] {
    --color-bg: #1a1a1a;
    --color-bg-alt: #252525;
    --color-text: #e4e4e4;
    --color-text-light: #a0a0a0;
    --color-white: #1e1e1e;
    --color-border: #3a3a3a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --color-surface: #252525;
    --color-surface-hover: #2d2d2d;
    --color-input-bg: #2a2a2a;
    --color-table-row-alt: #222;
    --color-modal-overlay: rgba(0,0,0,0.7);
    --color-primary: #7a7f7a;
    --color-primary-light: #4db8b8;

    /* Dark mode semantic colors */
    --color-success: #4ade80;
    --color-success-bg: #14532d;
    --color-success-text: #86efac;
    --color-warning: #fbbf24;
    --color-warning-bg: #451a03;
    --color-warning-text: #fde68a;
    --color-danger: #f87171;
    --color-danger-bg: #450a0a;
    --color-danger-text: #fca5a5;
    --color-info: #60a5fa;
    --color-info-bg: #1e3a5f;
    --color-info-text: #93c5fd;

    /* Dark mode status colors */
    --color-status-open: #60a5fa;
    --color-status-in-progress: #fbbf24;
    --color-status-waiting: #fb923c;
    --color-status-resolved: #4ade80;
    --color-status-closed: #9ca3af;

    --color-text-muted: #9ca3af;
}

/* Logo backdrop for manual dark theme */
[data-theme="dark"] #header img {
    background: rgba(255, 255, 255, 0.85);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
}

/* Light theme - manual override (for users who prefer light in dark OS) */
[data-theme="light"] {
    --color-bg: #f8f9f8;
    --color-bg-alt: #eef0ee;
    --color-text: #333;
    --color-text-light: #666;
    --color-white: #fff;
    --color-border: #d4ddd4;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --color-surface: #fff;
    --color-surface-hover: #f5f5f5;
    --color-input-bg: #fff;
    --color-table-row-alt: #f8f9f8;
    --color-modal-overlay: rgba(0,0,0,0.5);
    --color-primary: #5a5f5a;
    --color-primary-light: #3d9e9e;
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-bottom: var(--spacing-sm);
    color: var(--color-primary);
}

h3 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--color-primary-light);
    padding-bottom: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

p {
    margin-bottom: var(--spacing-sm);
}

/* Links */
a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

/* Header */
#header {
    background: linear-gradient(135deg, var(--color-white) 0%, var(--color-bg-alt) 100%);
    text-align: center;
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

#header img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Navigation */
#nav {
    background-color: var(--color-primary);
    padding: var(--spacing-xs) var(--spacing-sm);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

a.nav {
    display: inline-block;
    font-weight: 600;
    color: var(--color-white);
    background-color: var(--color-primary-light);
    padding: var(--spacing-xs) var(--spacing-md);
    text-decoration: none;
    border-radius: var(--border-radius);
    border: 2px solid var(--color-primary);
    transition: all var(--transition);
    font-size: 0.95rem;
}

a.nav:hover {
    background-color: var(--color-accent);
    border-color: var(--color-accent-dark);
    transform: translateY(-1px);
    text-decoration: none;
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-user {
    color: var(--color-white);
    font-weight: 600;
    padding: 0 var(--spacing-xs);
}

/* Main content wrapper */
.site-wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    background-color: var(--color-white);
    box-shadow: var(--shadow-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Main section */
#section {
    padding: var(--spacing-lg);
    flex: 1;
}

/* Menu links */
a.menu {
    display: block;
    font-weight: 600;
    color: var(--color-white);
    background-color: var(--color-primary);
    text-align: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    text-decoration: none;
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-xs);
    transition: all var(--transition);
}

a.menu:hover {
    background-color: var(--color-primary-light);
    text-decoration: none;
}

a.small_menu {
    display: inline-block;
    color: var(--color-white);
    background-color: var(--color-primary-light);
    text-align: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: all var(--transition);
}

a.small_menu:hover {
    background-color: var(--color-primary);
    text-decoration: none;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--spacing-md) 0;
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

th, td {
    padding: var(--spacing-xs) var(--spacing-sm);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background-color: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: var(--color-table-row-alt);
}

tr:hover {
    background-color: var(--color-surface-hover);
}

/* Forms */
form {
    margin: var(--spacing-md) 0;
}

input, textarea, select {
    display: block;
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--color-input-bg);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(61, 158, 158, 0.2);
}

/* Fix select dropdown arrow in dark mode */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    }
}

/* Date inputs need more width to be readable */
input[type="date"] {
    min-width: 9em;
    width: auto;
}

button, input[type="submit"] {
    background-color: var(--color-primary-light);
    color: var(--color-white);
    border: none;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: background-color var(--transition);
}

button:hover, input[type="submit"]:hover {
    background-color: var(--color-accent);
}

/* Lists */
ul, ol {
    margin: var(--spacing-sm) 0;
    padding-left: var(--spacing-lg);
}

li {
    margin-bottom: var(--spacing-xs);
}

/* Preformatted text / code blocks */
pre {
    background-color: var(--color-bg-alt);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    border: 1px solid var(--color-border);
    margin: var(--spacing-sm) 0;
}

/* Footer */
#footer {
    background-color: var(--color-primary);
    color: var(--color-white);
    text-align: center;
    padding: var(--spacing-sm);
    font-size: 0.9rem;
    margin-top: auto;
}

/* Facebook embed responsive */
.fb-page {
    margin: var(--spacing-sm) 0;
}

/* Contact info styling */
#section p b {
    color: var(--color-primary);
}

/* Responsive design */
@media (max-width: 768px) {
    :root {
        --spacing-lg: 1.5rem;
        --spacing-xl: 2rem;
    }

    #header {
        padding: var(--spacing-sm);
    }

    #header img {
        max-height: 80px;
    }

    #nav {
        padding: var(--spacing-sm);
    }

    a.nav {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.85rem;
    }

    #section {
        padding: var(--spacing-md);
    }

    h3 {
        font-size: 1.25rem;
    }

    pre {
        font-size: 0.65rem;
        padding: var(--spacing-xs);
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: var(--spacing-xs);
    }
}

@media (max-width: 480px) {
    a.nav {
        flex: 1 1 auto;
        text-align: center;
    }

    #section {
        padding: var(--spacing-sm);
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .site-wrapper {
        box-shadow: none;
    }

    #nav {
        display: none;
    }

    #footer {
        position: static;
        background: none;
        color: var(--color-text);
        border-top: 1px solid var(--color-border);
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Margin utilities */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.ml-sm { margin-left: 0.5rem; }

/* Width utilities */
.w-auto { width: auto; }
.w-full { width: 100%; }

/* Text utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-muted { color: var(--color-text-light); }
.text-success { color: #22c55e; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-sm { font-size: 0.9em; }
.text-xs { font-size: 0.8rem; }
.font-bold { font-weight: bold; }
.nowrap { white-space: nowrap; }

/* Flexbox utilities */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* Display utilities */
.inline { display: inline; }
.inline-block { display: inline-block; }
.block { display: block; }
.hidden { display: none; }

/* ==========================================================================
   Component Classes
   ========================================================================== */

/* Card/Panel */
.card {
    background: var(--color-bg-alt);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
}

/* Modal overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-modal-overlay);
    z-index: 1000;
}

/* Modal content */
.modal-content {
    background: var(--color-surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    max-width: 500px;
    margin: 100px auto;
    position: relative;
    color: var(--color-text);
}

.modal-content-sm { max-width: 400px; }
.modal-content-lg { max-width: 600px; }
.modal-content-wide { max-width: 700px; }

/* Confirm Modal */
.confirm-modal {
    text-align: center;
    padding: 2rem 1.5rem;
}

.confirm-icon {
    margin-bottom: 1rem;
    color: var(--color-primary);
}

.confirm-icon.warning {
    color: #f59e0b;
}

.confirm-icon.danger {
    color: #ef4444;
}

.confirm-icon svg {
    width: 48px;
    height: 48px;
}

.confirm-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.confirm-message {
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.confirm-actions button {
    min-width: 100px;
    padding: 0.5rem 1.25rem;
}

/* Inline form */
.form-inline {
    display: inline;
    margin: 0;
}

/* Button variants */
.btn-sm {
    padding: 2px 8px;
    font-size: 0.8rem;
}

.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: #22c55e; }
.btn-success:hover { background: #16a34a; }

.btn-secondary { background: var(--color-text-light); }
.btn-secondary:hover { background: #4b5563; }

.btn-warning { background: #f59e0b; color: #000; }
.btn-warning:hover { background: #d97706; }

.btn-info { background: #3b82f6; }
.btn-info:hover { background: #2563eb; }

/* Message/alert styling */
.message {
    color: var(--color-primary-light);
    font-weight: bold;
}
.message-success { color: #22c55e; font-weight: bold; }
.message-error { color: #ef4444; font-weight: bold; }

/* Table utilities */
.table-responsive { overflow-x: auto; }

table.table-min-500 { min-width: 500px; }
table.table-min-600 { min-width: 600px; }
table.table-min-700 { min-width: 700px; }

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    white-space: nowrap;
}

th.sortable a {
    color: inherit;
    text-decoration: none;
    display: block;
}

th.sortable a:hover {
    color: var(--color-primary-light);
}

/* Form grid layouts */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.form-grid-4 {
    display: grid;
    grid-template-columns: 100px 150px auto 1fr;
    gap: var(--spacing-sm);
}

/* Form rows with better spacing for modals */
.form-row {
    margin-bottom: var(--spacing-md);
}

.form-row label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.form-row input,
.form-row select,
.form-row textarea {
    margin-bottom: 0;
}

.form-row-group {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.form-row-group .form-row {
    flex: 1;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.form-actions .spacer {
    flex: 1;
}

/* Checkbox/label inline */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

/* Section header with count */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.section-header h4 {
    margin: 0;
}

/* Filter controls container */
.filter-controls {
    background: var(--color-bg-alt);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
}

.filter-controls form {
    margin: 0;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
}

.pagination .current {
    padding: 4px 10px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--border-radius);
}

/* Tab navigation */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: var(--spacing-sm);
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.tab-btn.active {
    background: var(--color-bg-alt);
    border-bottom: 2px solid var(--color-primary);
    color: var(--color-primary);
}

.tab-btn:hover {
    background: var(--color-bg-alt);
}

.tab-panel {
    padding-top: var(--spacing-sm);
}

/* Action menu dropdown */
.action-menu {
    display: inline-block;
}

.action-menu-btn {
    padding: 4px 10px;
    font-size: 0.85rem;
}

.action-menu-dropdown {
    display: none;
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 9999;
    min-width: 160px;
    padding: 4px 0;
}

.action-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text);
    text-decoration: none;
}

.action-item:hover {
    background: var(--color-surface-hover);
    text-decoration: none;
}

/* Responsive form grids */
@media (max-width: 768px) {
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Theme Toggle Button
   ========================================================================== */

.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    line-height: 1;
    transition: background-color var(--transition);
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* Icon visibility based on theme */
.theme-icon-light,
.theme-icon-dark,
.theme-icon-auto {
    display: none;
}

/* Default (auto) - show auto icon */
:root:not([data-theme]) .theme-icon-auto { display: inline; }
:root:not([data-theme]) .theme-icon-light { display: none; }
:root:not([data-theme]) .theme-icon-dark { display: none; }

/* Manual light theme - show sun */
[data-theme="light"] .theme-icon-light { display: inline; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-auto { display: none; }

/* Manual dark theme - show moon */
[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-auto { display: none; }

/* Smooth color transitions for theme changes */
body,
.card,
.modal-content,
.filter-controls,
table,
input, textarea, select,
.action-menu-dropdown {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Impersonation modal specific styles */
.impersonate-modal-body {
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.impersonate-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
}

.impersonate-loading {
    padding: 12px;
    color: var(--color-text-light);
}

.impersonate-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 1rem;
}

.impersonate-item:hover {
    background: var(--color-surface-hover);
}

/* Icon Grid for Dashboards */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.icon-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--color-text);
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.icon-card:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.icon-card-icon {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 1rem;
}

.icon-card-label {
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
}

/* ============================================
   Status & State Utility Classes
   ============================================ */

/* Ticket status colors */
.status-open { color: var(--color-status-open); font-weight: bold; }
.status-in-progress { color: var(--color-status-in-progress); font-weight: bold; }
.status-waiting { color: var(--color-status-waiting); font-weight: bold; }
.status-resolved { color: var(--color-status-resolved); font-weight: bold; }
.status-closed { color: var(--color-status-closed); font-weight: bold; }

/* Server/service status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}
.status-online { color: var(--color-success); }
.status-down { color: var(--color-danger); }
.status-dot {
    font-size: 1.5rem;
    line-height: 1;
}

/* Invoice/billing status */
.invoice-paid { color: var(--color-success); }
.invoice-closed { color: var(--color-success); }
.invoice-open { color: var(--color-danger); }

/* Button variants */
.btn-danger {
    background-color: var(--color-danger);
    border-color: var(--color-danger);
    color: var(--color-white);
}
.btn-danger:hover {
    background-color: var(--color-danger-text);
    border-color: var(--color-danger-text);
}

/* Alert/banner styles */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
}
.alert-warning {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning);
    color: var(--color-warning-text);
}
.alert-danger {
    background: var(--color-danger-bg);
    border: 1px solid var(--color-danger);
    color: var(--color-danger-text);
}
.alert-success {
    background: var(--color-success-bg);
    border: 1px solid var(--color-success);
    color: var(--color-success-text);
}
.alert-info {
    background: var(--color-info-bg);
    border: 1px solid var(--color-info);
    color: var(--color-info-text);
}

/* Impersonation banner */
.impersonation-banner {
    background: var(--color-warning);
    color: #000;
    padding: 8px 16px;
    text-align: center;
    font-weight: 500;
}
.impersonation-banner button {
    background: var(--color-white);
    color: #000;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.dev-banner {
    background: #e53935;
    color: #fff;
    padding: 8px 16px;
    text-align: center;
    font-weight: bold;
    font-size: 0.9em;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Chat Widget & Support System
   ========================================================================== */

/* Main chat widget container - fixed position in bottom right */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    font-family: inherit;
}

/* Toggle button - the circular chat icon */
.chat-widget-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
    position: relative;
}

.chat-widget-toggle:hover {
    background: var(--color-primary);
    transform: scale(1.05);
}

/* Show/hide icons based on open state */
.chat-widget-icon { display: flex; }
.chat-widget-toggle .chat-widget-close { display: none; }
.chat-widget-open .chat-widget-icon { display: none; }
.chat-widget-open .chat-widget-toggle .chat-widget-close { display: flex; }

/* Notification badge */
.chat-widget-toggle.has-notification::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--color-danger);
    border-radius: 50%;
    border: 2px solid var(--color-surface);
}

/* Chat panel - hidden by default, shown when open */
.chat-widget-panel {
    display: none;
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    overflow: hidden;
}

.chat-widget-open .chat-widget-panel {
    display: flex;
}

/* Panel header */
.chat-widget-header {
    background: var(--color-primary-light);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 1rem;
    color: white;
    border: none;
    padding: 0;
}

.chat-widget-status {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Panel body */
.chat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Loading state */
.chat-widget-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
    padding: 20px;
}

/* Error state */
.chat-widget-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    color: var(--color-text-light);
}

.chat-retry-btn {
    margin-top: 12px;
}

/* Intro form for anonymous visitors */
.chat-widget-intro {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.chat-widget-intro p {
    margin-bottom: 16px;
    color: var(--color-text);
}

.chat-init-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.chat-init-form .chat-input {
    margin: 0;
}

.chat-submit-btn {
    margin-top: 4px;
}

/* Messages container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual message */
.chat-message {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
}

.chat-message-user {
    align-self: flex-end;
    background: var(--color-primary-light);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-admin {
    align-self: flex-start;
    background: var(--color-bg-alt);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}

.chat-message-content {
    line-height: 1.4;
    white-space: pre-wrap;
}

.chat-message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
}

/* Typing indicator */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--color-bg-alt);
    border-radius: 12px;
    align-self: flex-start;
    max-width: 60px;
}

.chat-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--color-text-light);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.chat-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.chat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Input form */
.chat-input-form {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
    margin: 0;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    resize: none;
    border-radius: var(--border-radius);
    min-height: 38px;
    max-height: 100px;
    margin: 0;
    padding: 8px 12px;
}

.chat-send-btn {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chat-widget-panel {
        width: calc(100vw - 40px);
        right: 0;
        left: 20px;
    }
}

/* ==========================================================================
   User Chat Page (Full Page)
   ========================================================================== */

.user-chat-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    height: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-chat-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
}

.user-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chat-form {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 12px;
    margin: 0;
}

.user-chat-input {
    flex: 1;
    resize: none;
    margin: 0;
    min-height: 44px;
    max-height: 120px;
}

/* ==========================================================================
   Admin Chat Management Page
   ========================================================================== */

/* Main layout - sidebar + main content */
.admin-chat-layout {
    display: flex;
    height: 600px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--color-surface);
}

/* Sidebar with conversation list */
.admin-chat-sidebar {
    width: 300px;
    min-width: 300px;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    background: var(--color-bg-alt);
}

.admin-chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface);
}

.admin-chat-sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-text);
    border: none;
    padding: 0;
}

.admin-chat-conversations {
    flex: 1;
    overflow-y: auto;
}

/* Conversation item in list */
.conversation-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background var(--transition);
}

.conversation-item:hover {
    background: var(--color-surface-hover);
}

.conversation-item.selected {
    background: var(--color-primary-light);
    color: white;
}

.conversation-item.selected .conversation-preview,
.conversation-item.selected .conversation-time {
    color: rgba(255, 255, 255, 0.85);
}

.conversation-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.conversation-preview {
    font-size: 0.85rem;
    color: var(--color-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--color-text-light);
}

/* Unread badge */
.unread-badge {
    background: var(--color-danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* Empty/loading states */
.admin-chat-conversations .loading,
.admin-chat-conversations .error,
.admin-chat-conversations .no-conversations {
    padding: 20px;
    text-align: center;
    color: var(--color-text-light);
}

.admin-chat-conversations .error {
    color: var(--color-danger);
}

/* Main chat area */
.admin-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Chat header with user info */
.admin-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface);
}

.admin-chat-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-chat-user-info strong {
    font-size: 1rem;
}

.admin-chat-user-info .email {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.admin-chat-actions {
    display: flex;
    gap: 8px;
}

.btn-close-conv {
    background: var(--color-text-light);
    font-size: 0.85rem;
    padding: 6px 12px;
}

.btn-close-conv:hover {
    background: var(--color-danger);
}

/* Messages area */
.admin-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message footer with input */
.admin-chat-footer {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.admin-chat-form {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin: 0;
}

.admin-chat-input {
    flex: 1;
    resize: none;
    margin: 0;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 12px;
}

.admin-chat-send {
    align-self: flex-end;
    padding: 10px 20px;
}

/* Empty state when no conversation selected */
.admin-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-chat-layout {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }

    .admin-chat-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .admin-chat-main {
        min-height: 400px;
    }

    .chat-widget-panel {
        bottom: 70px;
        right: 0;
        left: 10px;
        width: auto;
        max-width: none;
    }
}
