:root {
    /* Brand Color Palette - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f4f4f5;
    --bg-card: #ffffff;

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;

    --accent-primary: #a32f96;
    --accent-glow: rgba(163, 47, 150, 0.2);
    --accent-hover: #802476;

    --accent-secondary: #a58eb3;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --border-subtle: #e4e4e7;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-subtle);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.app-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--accent-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Auth State UI */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.hidden {
    display: none !important;
}

/* Actions Bar & Filters */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.category-filters {
    display: none; /* Hidden by default, shown via JS for Supervisors */
}

.filter-select {
    padding: 0.6rem 2.5rem 0.6rem 1rem; /* Extra right padding for arrow */
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    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='currentColor' 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 0.7rem center;
    background-size: 1em;
    min-width: 200px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.action-buttons {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.nav-btn {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-btn.active {
    color: var(--accent-primary);
    background: rgba(163, 47, 150, 0.05);
}

/* Stats View */
.stats-container {
    background: white;
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid var(--border-subtle);
}

.stats-container h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.stats-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.stats-card.full-width {
    grid-column: 1 / -1;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.stats-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stats-summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stats-summary-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.stats-summary-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stats-card canvas {
    width: 100%;
    height: 260px;
}

#stats-map {
    width: 100%;
    height: 320px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Ticket Grid */
.ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.ticket-card {
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ticket-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(163, 47, 150, 0.15);
    border-color: var(--accent-secondary);
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticket-id {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: 700;
    color: var(--accent-primary);
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.ticket-body {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.label {
    color: var(--text-muted);
}

.value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Status Indicators */
.status-badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge.open {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.closed {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-secondary);
}

.status-badge::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 8px currentColor;
}

/* Reminders */
.reminders-section h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.reminder-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.reminder-chip {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
    transition: all 0.2s;
}

.reminder-chip.sent {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.reminder-chip.pending {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.reminder-chip span {
    font-weight: 700;
}

.reminder-chip small {
    opacity: 0.8;
}

/* Skeleton & Staggered */
.skeleton-card {
    height: 300px;
    background: linear-gradient(90deg, #f4f4f5 25%, #e4e4e7 50%, #f4f4f5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.ticket-card {
    opacity: 0;
    animation: fadeIn 0.4s ease-out forwards;
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    z-index: 2000;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 280px;
    animation: slideInRight 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    border-left: 4px solid var(--accent-primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.fade-out {
    animation: fadeOutDown 0.3s forwards;
}

@keyframes fadeOutDown {
    to {
        transform: translateY(20px);
        opacity: 0;
    }
}

/* Table in Modal */
.reminders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.reminders-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.reminders-table td {
    padding: 0.8rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
}

.status-sent {
    color: var(--success);
    font-weight: 600;
}

.status-pending {
    color: var(--danger);
    font-weight: 600;
}

/* Buttons */
.ticket-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 1rem;
}

button {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.refresh-btn {
    background: white;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.refresh-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    position: relative;
    overflow-y: auto;
    transform: scale(0.9);
    transition: all 0.3s;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
}

.modal-header {
    margin-bottom: 2rem;
}

.modal-subtitle {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 1.1rem;
}

.modal-section {
    margin-bottom: 2.5rem;
}

.modal-section h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-value {
    font-weight: 500;
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Loader */
.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--bg-secondary);
    border-bottom-color: var(--accent-primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
