:root {
    /* Palette: Cyberpunk/Neon */
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --primary: #8b5cf6;
    /* Violet */
    --primary-glow: #8b5cf688;
    --secondary: #06b6d4;
    /* Cyan */
    --accent: #f43f5e;
    /* Rose */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    /* Analysis / Warning Accent */
    --accent-secondary: #e2e8f0;
    /* Silver / Slate-200 */
    --accent-secondary-rgb: 226, 232, 240;

    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Effect */
#background-glow {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.15), transparent 60%),
        radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.1), transparent 50%);
    z-index: -1;
    animation: pulse 10s ease-in-out infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Glassmorphism */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

/* Navbar */
#navbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1200px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo img,
.nav-logo {
    display: inline-block;
    vertical-align: middle;
    filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0.3));
    transition: all 0.3s ease;
}

.logo img:hover,
.nav-logo:hover {
    filter: drop-shadow(0 0 12px var(--primary));
    transform: translateY(-1px) scale(1.02);
}

.logo i {
    color: var(--secondary);
    filter: drop-shadow(0 0 5px var(--secondary));
}

.logo .highlight {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px 16px;
    border-radius: 8px;
}

.nav-btn:hover,
.nav-btn.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-heading);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent), #be123c);
    color: white;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Form Elements */
input,
select,
textarea {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    width: 100%;
    font-family: var(--font-body);
    margin-bottom: 5px;
    /* Spacing */
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

/* Layouts */
#main-content {
    padding-top: 120px;
    padding-bottom: 50px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    width: 100%;
}

.center-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Login View */
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    text-align: center;
}

.login-card h1 {
    margin-bottom: 30px;
    font-weight: 300;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}


/* Dashboard Filters */
.dashboard-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    width: 90%;
    max-width: 1400px;
    margin-bottom: 20px;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 12px;
    border: var(--glass-border);
}

.dashboard-controls h2 {
    margin-right: auto;
    font-size: 1.5rem;
}

.filter-group {
    display: flex;
    gap: 10px;
}

.filter-select {
    width: auto;
    min-width: 120px;
    margin-bottom: 0;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    width: 90%;
    max-width: 1400px;
}

/* Ticket Card */
.ticket-card {
    padding: 20px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-left: 4px solid transparent;
}

.ticket-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary);
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.ticket-id {
    font-family: monospace;
    color: var(--text-muted);
    font-size: 0.9em;
}

.ticket-priority {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
}

.priority-critical {
    background: rgba(244, 63, 94, 0.2);
    color: var(--accent);
    border: 1px solid var(--accent);
    animation: flash 2s infinite;
}

.priority-high {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

.priority-medium {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.priority-low {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.priority-doc {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.text-critical {
    color: var(--accent) !important;
}

.text-high {
    color: #f97316 !important;
}

.text-medium {
    color: #eab308 !important;
}

.text-low {
    color: #22c55e !important;
}

.text-doc {
    color: #94a3b8 !important;
}

.ticket-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.ticket-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 15px;
}

@keyframes flash {

    0%,
    100% {
        box-shadow: 0 0 5px var(--accent);
    }

    50% {
        box-shadow: 0 0 15px var(--accent);
    }
}

/* Wizard */
.wizard-container {
    width: 90%;
    max-width: 600px;
    padding: 40px;
}

.wizard-step {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wizard-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.option-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.02);
}

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--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);
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-panel);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 0;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: inherit;
    /* retain glass effect if needed, or opaque */
    background: rgba(30, 41, 59, 0.95);
    z-index: 10;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-main);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

.modal-section {
    margin-bottom: 30px;
}

.modal-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.info-item span {
    font-size: 1rem;
    font-weight: 500;
}

.ticket-description {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 8px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Activity Log */
.activity-log {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.activity-item {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
}

.activity-date {
    color: var(--text-muted);
    min-width: 140px;
    font-variant-numeric: tabular-nums;
}

.activity-content {
    flex: 1;
}

.activity-user {
    font-weight: 600;
    color: var(--secondary);
    margin-right: 5px;
}


/* View Toggles */
.view-toggle {
    display: flex;
    gap: 5px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.view-toggle .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    background: transparent;
    color: var(--text-muted);
}

.view-toggle .btn-icon.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 10px var(--primary-glow);
}

/* Dashboard List Mode */
.dashboard-list {
    display: block;
    /* Override grid */
    width: 90%;
    max-width: 1400px;
}

.ticket-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Gap between rows */
}

.ticket-table th {
    text-align: left;
    padding: 15px 20px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.ticket-table tbody tr {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
    cursor: pointer;
}

.ticket-table tbody tr:hover {
    transform: translateY(-2px);
    background: rgba(30, 41, 59, 0.9);
}

.ticket-table td {
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-width: 1px 0;
}

.ticket-table td:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.ticket-table td:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Compact Table Utility */
.compact-table th {
    padding: 10px 12px;
    font-size: 0.75rem;
}

.compact-table td {
    padding: 12px 15px;
    font-size: 0.9rem;
}

/* Form Priority Selection */
.priority-selector {
    display: flex;
    gap: 15px;
    margin-top: 5px;
}

.priority-option {
    cursor: pointer;
    opacity: 0.4;
    transition: var(--transition);
    border: 1px solid transparent;
    filter: grayscale(0.5);
    font-size: 0.75rem;
    /* Match ticket badge size approx */
    padding: 8px 16px;
}

.priority-option:hover {
    opacity: 0.7;
    filter: grayscale(0);
    transform: translateY(-2px);
}

.priority-option.selected {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ============================================
   PAGINATION CONTROLS
   ============================================ */

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 25px 20px;
    margin-top: 20px;
    background: var(--glass-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.pagination-btn {
    padding: 10px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.pagination-btn i {
    font-size: 0.8rem;
}

.pagination-number {
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.pagination-number:hover {
    background: var(--glass-hover);
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.pagination-number.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.page-info {
    padding: 0 15px;
    display: flex;
    align-items: center;
}

.page-info strong {
    color: var(--accent-primary);
    font-size: 1.1em;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .pagination-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .pagination-number {
        min-width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    .page-info {
        width: 100%;
        justify-content: center;
        order: -1;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border-color);
    }
}

/* Responsive Design (Mobile) */
@media (max-width: 768px) {

    /* Navbar Compact Mode */
    #navbar {
        top: 0;
        width: 100%;
        max-width: 100%;
        height: 60px;
        padding: 0 15px;
        border-radius: 0;
        border-top: none;
        border-left: none;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(15, 23, 42, 0.95);
        /* Opaque background for readability */
    }

    /* Logo - resize */
    .logo img {
        height: 24px !important;
    }

    /* Nav Links - Icon Only Mode */
    .nav-links {
        gap: 8px;
    }

    .nav-btn {
        font-size: 0 !important;
        /* Hide Text */
        padding: 8px;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-btn i {
        font-size: 1.1rem;
        margin: 0;
    }

    /* New Ticket Button - Convert to Icon Button */
    .nav-links .btn-primary {
        font-size: 0 !important;
        /* Hide Text */
        padding: 0;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: none;
    }

    .nav-links .btn-primary i {
        font-size: 1.1rem;
        margin: 0;
        /* Remove margin-right typically on icon */
    }

    /* User Profile */
    #nav-username {
        display: none;
        /* Hide Username */
    }

    .user-profile {
        gap: 8px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    /* Main Content */
    #main-content {
        padding-top: 80px;
        /* Adjust for smaller header */
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Dashboard Controls Stack */
    .dashboard-controls {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }

    /* Header Row (Title + Search) */
    .dashboard-controls>div:first-child {
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px;
    }

    .dashboard-controls h2 {
        justify-content: space-between;
        font-size: 1.3rem;
    }

    #search-input {
        width: 100% !important;
        margin: 0;
    }

    .view-toggle {
        display: none;
    }

    /* Filters - Full Width Stack */
    .dashboard-controls>div:last-child {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .filter-select {
        width: 100%;
        min-width: 0;
    }

    /* Ticket Grid - Single Column */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Ticket List - Horizontal Scroll */
    .dashboard-list {
        overflow-x: auto;
    }

    .ticket-table {
        min-width: 600px;
        /* Force scroll */
    }

    /* Wizard Container */
    .wizard-container {
        padding: 20px;
        width: 100%;
    }

    .wizard-options {
        grid-template-columns: 1fr;
    }

    /* Modals */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-grid {
        grid-template-columns: 1fr;
    }

    .info-item[style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }
}

@media print {
    body {
        background: white !important;
        color: black !important;
    }

    #navbar,
    .dashboard-controls,
    .btn-icon,
    .modal-close,
    #save-ticket-btn,
    .pagination-controls,
    #background-glow {
        display: none !important;
    }

    .modal-overlay {
        background: white !important;
        position: static !important;
    }

    .modal-content {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: none !important;
        position: static !important;
        width: 100% !important;
        overflow: visible !important;
    }

    .modal-section h3 {
        border-bottom: 2px solid #eee !important;
        color: #666 !important;
    }

    .ticket-description {
        background: #f9f9f9 !important;
        border: 1px solid #eee !important;
        color: black !important;
    }

    .comment-item {
        background: #f9f9f9 !important;
        border: 1px solid #eee !important;
        color: black !important;
    }

    .print-logo-pdf {
        display: block !important;
        max-width: 300px;
        margin-bottom: 20px;
    }
}

/* Colorfix for date picker icons */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}