/* ============================================
   Helpdesk System - Consolidated Stylesheet
   ============================================ */

/* CSS Custom Properties (Design Tokens) */
:root {
    /* Brand palette: dark blue + gray */
    --primary: #1e3a5f;
    --primary-dark: #152a45;
    --primary-light: #2f5d8a;
    /* Legacy alias: existing rules use var(--primary-teal) */
    --primary-teal: var(--primary);

    --bg-slate: #f3f4f6;
    --surface: #ffffff;
    --text-slate: #1f2937;
    --text-muted: #64748b;
    --border-slate: #e5e7eb;

    --accent-orange: #f97316;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
}

/* Base */
body {
    font-family: 'Raleway', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-slate);
    color: var(--text-slate);
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 20px;
    background-color: #1f2937;
    color: #e5e7eb;
}

/* ============================================
   Sidebar Navigation
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    background: linear-gradient(180deg, #0f1e33 0%, #1e3a5f 100%);
    color: #fff;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-logo {
    display: block;
    width: 100%;
    max-width: 168px;
    height: auto;
}

.sidebar-brand span {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    opacity: 0.8;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav li a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: #fff;
    font-weight: 700;
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 0;
    transition: color 0.2s;
}

.sidebar-logout:hover { color: #fff; }

/* Main content offset for sidebar */
.sidebar-main {
    margin-left: 240px;
    padding: 20px 24px;
    min-height: 100vh;
}

.sidebar-footer-bar {
    margin-left: 240px;
}

/* Sidebar toggle button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 14px;
    left: 254px;
    z-index: 1100;
    background: var(--primary-teal);
    color: #fff;
    border: none;
    border-radius: 0 8px 8px 0;
    width: 28px;
    height: 38px;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.15);
    transition: left 0.3s ease;
}

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

.sidebar-overlay.open { display: block; }

/* Desktop collapsed state */
.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar.collapsed .sidebar-brand::before {
    content: "CS";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #ffffff;
    color: #0d7fc4;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    border-radius: 9px;
}

.sidebar.collapsed .sidebar-user-info {
    display: none;
}

.sidebar.collapsed .sidebar-nav li a {
    font-size: 0;
    justify-content: center;
    padding: 12px 0;
    border-left: none;
    gap: 0;
}

.sidebar.collapsed .sidebar-nav li a i {
    font-size: 1.1rem;
    width: auto;
}

.sidebar.collapsed .sidebar-logout {
    font-size: 0;
    justify-content: center;
    gap: 0;
}

.sidebar.collapsed .sidebar-logout i {
    font-size: 1.1rem;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 18px 0;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 16px 0;
}

.sidebar.collapsed .sidebar-footer {
    padding: 16px 0;
}

.sidebar.collapsed .sidebar-nav li {
    position: relative;
}

.sidebar.collapsed .sidebar-nav li a::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    margin-left: 8px;
    z-index: 100;
}

.sidebar.collapsed .sidebar-nav li a:hover::after {
    opacity: 1;
}

.sidebar.collapsed .sidebar-footer {
    position: relative;
}

.sidebar.collapsed .sidebar-logout::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    margin-left: 8px;
    z-index: 100;
}

.sidebar.collapsed .sidebar-logout:hover::after {
    opacity: 1;
}

.sidebar-toggle.collapsed {
    left: 74px;
}

.sidebar-main.sidebar-collapsed,
.sidebar-footer-bar.sidebar-collapsed {
    margin-left: 60px;
}

/* Mobile: sidebar collapses off-screen */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 240px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        left: 14px;
        border-radius: 8px;
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    .sidebar-main,
    .sidebar-footer-bar {
        margin-left: 0;
    }
    .sidebar-main {
        padding: 70px 16px 16px;
    }
    .sidebar.collapsed .sidebar-brand span {
        display: initial;
    }
    .sidebar.collapsed .sidebar-logo {
        display: block;
    }
    .sidebar.collapsed .sidebar-brand::before {
        content: none;
    }
    .sidebar.collapsed .sidebar-user-info {
        display: flex;
    }
    .sidebar.collapsed .sidebar-nav li a {
        font-size: 0.9rem;
        justify-content: flex-start;
        padding: 12px 20px;
        border-left: 3px solid transparent;
        gap: 12px;
    }
    .sidebar.collapsed .sidebar-nav li a i {
        font-size: 1rem;
        width: 20px;
    }
    .sidebar.collapsed .sidebar-logout {
        font-size: 0.9rem;
        justify-content: flex-start;
        gap: 10px;
    }
    .sidebar.collapsed .sidebar-logout i {
        font-size: 1rem;
    }
    .sidebar.collapsed .sidebar-brand {
        justify-content: flex-start;
        padding: 24px 20px 20px;
    }
    .sidebar.collapsed .sidebar-user {
        justify-content: flex-start;
        padding: 16px 20px;
    }
    .sidebar.collapsed .sidebar-footer {
        padding: 16px 20px;
    }
}

/* ============================================
   Auth Pages (Login & Register)
   ============================================ */
body.no-sidebar {
    background: linear-gradient(135deg, #0f1e33 0%, #1e3a5f 55%, #374151 100%);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    overflow: hidden;
}

.auth-card-header {
    text-align: center;
    padding: 36px 32px 0;
}

.auth-card-header .auth-logo {
    display: block;
    width: 200px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 18px;
}

.auth-card-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-slate);
    margin: 0 0 4px;
}

.auth-card-header p {
    font-size: 0.88rem;
    color: #64748b;
    margin: 0;
}

.auth-card-body {
    padding: 28px 32px 32px;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
    transition: color 0.2s;
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 40px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.92rem;
    font-family: 'Raleway', Arial, sans-serif;
    color: var(--text-slate);
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
}

.auth-input::placeholder {
    color: #a0aec0;
    font-size: 0.85rem;
}

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,0.15);
    background: #fff;
}

.auth-input:focus + i,
.auth-input:focus ~ i {
    color: var(--primary);
}

.auth-input.field-error-border {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.auth-btn {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #152a45, #1e3a5f);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Raleway', Arial, sans-serif;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(30,58,95,0.3);
    margin-top: 4px;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(30,58,95,0.35);
}

.auth-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(30,58,95,0.25);
}

.auth-footer-text {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: #64748b;
}

.auth-footer-text a {
    color: var(--primary-teal);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-footer-text a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-message {
    margin: 0 0 4px;
    padding: 0;
}

@media (max-width: 768px) {
    .auth-page {
        padding: 24px 16px;
        align-items: flex-start;
        padding-top: 48px;
    }
    .auth-card {
        border-radius: 12px;
    }
    .auth-card-header {
        padding: 28px 24px 0;
    }
    .auth-card-body {
        padding: 24px;
    }
}

.ticket-form-card {
    width: 60%;
    max-width: 800px;
    margin: auto;
    padding: 20px;
}

@media (max-width: 768px) {
    .ticket-form-card {
        width: 95%;
    }
}

/* ============================================
   Shared Dashboard Styles
   ============================================ */

/* Modern Table */
.modern-table-container {
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: transparent;
}

.modern-table th {
    background-color: #f1f5f9;
    color: #475569;
    font-weight: 600;
    padding: 16px;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
}

.modern-table tr {
    background-color: #ffffff;
    transition: background-color 0.2s ease;
}

.modern-table tbody tr:hover {
    background-color: #f8fafc;
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
}

.modern-table tr:last-child td {
    border-bottom: none;
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-open { background-color: #fee2e2; color: #991b1b; }
.badge-progress { background-color: #dbeafe; color: #1e40af; }
.badge-closed { background-color: #dcfce7; color: #166534; }
.badge-reopened { background-color: #f3e8ff; color: #6b21a8; }

.badge-low { background-color: #f1f5f9; color: #475569; }
.badge-medium { background-color: #fef3c7; color: #92400e; }
.badge-high { background-color: #ffedd5; color: #c2410c; }
.badge-critical { background-color: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

.badge-overdue {
    background-color: #ef4444;
    color: #ffffff;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Filter Pills */
.filter-pill {
    border-radius: 20px;
    padding: 6px 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    margin: 4px;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    color: #475569;
    text-decoration: none;
    display: inline-block;
}

.filter-pill:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}

.filter-pill.active {
    background-color: var(--primary-teal);
    color: #ffffff;
    border-color: var(--primary-teal);
}

/* Stat Cards */
.stat-card,
.stat-card-mini {
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
    border-left: 4px solid var(--primary-teal);
}

.stat-card:hover,
.stat-card-mini:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

/* Gradient Cards */
.gradient-blue { background: linear-gradient(135deg, #1e3a5f, #2f5d8a); }
.gradient-orange { background: linear-gradient(135deg, #f97316, #ea580c); }
.gradient-green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.gradient-purple { background: linear-gradient(135deg, #334155, #64748b); }

/* Card Container */
.card-container {
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Edit Input */
.edit-input {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.edit-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.2);
}

/* Tab Buttons */
.tab-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--primary-teal);
}

.tab-btn.active {
    color: var(--primary-teal);
    border-bottom-color: var(--primary-teal);
}

/* Action Select */
.action-select {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Role Badges */
.badge-admin { background-color: #fee2e2; color: #991b1b; }
.badge-agent { background-color: #dbeafe; color: #1e40af; }
.badge-user { background-color: #dcfce7; color: #166534; }

/* Priority badge aliases (used in admin dashboard tables) */
.priority-low      { background-color: #f1f5f9; color: #475569; }
.priority-medium   { background-color: #fef3c7; color: #92400e; }
.priority-high     { background-color: #ffedd5; color: #c2410c; }
.priority-critical { background-color: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

/* AJAX Message Panels */
.ajax-message {
    display: none;
}

.ajax-message.success {
    background-color: #dcfce7;
    color: #166534;
}

.ajax-message.error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Inline Field Validation */
.field-error {
    display: block;
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 4px;
    min-height: 1em;
}

.w3-input.field-error-border,
.w3-select.field-error-border {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px #ef4444;
}

/* Deadline Warning Banner */
.deadline-warning-banner {
    display: none;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-left: 5px solid #d97706;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 12px 0;
    animation: deadline-warning-flash 0.6s ease;
    position: relative;
}

.deadline-warning-banner::before {
    content: '\f071';
    font-family: 'FontAwesome';
    font-size: 1.3rem;
    color: #d97706;
    margin-right: 10px;
    vertical-align: middle;
}

.deadline-warning-banner .deadline-warning-title {
    font-weight: 700;
    color: #92400e;
    font-size: 0.95rem;
    display: inline;
}

.deadline-warning-banner .deadline-warning-detail {
    display: block;
    color: #78350f;
    font-size: 0.88rem;
    margin-top: 4px;
    line-height: 1.4;
}

.deadline-warning-banner .deadline-warning-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #92400e;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.deadline-warning-banner .deadline-warning-close:hover {
    opacity: 1;
}

@keyframes deadline-warning-flash {
    0% { opacity: 0; transform: translateY(-6px); }
    50% { opacity: 1; }
    100% { transform: translateY(0); }
}

/* Deadline input warning state */
.deadline-input-warning {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25) !important;
}

/* Server-side deadline warning (after submission) */
.deadline-server-warning {
    display: none;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 2px solid #ea580c;
    border-left: 5px solid #c2410c;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 12px 0;
    animation: deadline-warning-flash 0.6s ease;
}

.deadline-server-warning::before {
    content: '\f071';
    font-family: 'FontAwesome';
    font-size: 1.3rem;
    color: #c2410c;
    margin-right: 10px;
    vertical-align: middle;
}

.deadline-server-warning .deadline-server-warning-title {
    font-weight: 700;
    color: #9a3412;
    font-size: 0.95rem;
    display: inline;
}

.deadline-server-warning .deadline-server-warning-detail {
    display: block;
    color: #7c2d12;
    font-size: 0.88rem;
    margin-top: 4px;
    line-height: 1.4;
}

/* ============================================
   W3.CSS brand overrides: teal/blue -> dark blue
   W3.CSS declares its colour helpers with
   !important, so these need !important too.
   ============================================ */
.w3-teal,
.w3-hover-teal:hover,
.w3-hover-teal:focus {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.w3-text-teal,
.w3-hover-text-teal:hover,
.w3-hover-text-teal:focus {
    color: var(--primary) !important;
}

.w3-border-teal {
    border-color: var(--primary) !important;
}

/* Secondary blue actions (e.g. Edit buttons, pending SLA) */
.w3-blue,
.w3-hover-blue:hover,
.w3-hover-blue:focus {
    background-color: var(--primary-light) !important;
    color: #ffffff !important;
}

.w3-text-blue,
.w3-hover-text-blue:hover,
.w3-hover-text-blue:focus {
    color: var(--primary-light) !important;
}

/* Neutral gray surfaces */
.w3-light-grey,
.w3-hover-light-grey:hover,
.w3-hover-light-grey:focus {
    background-color: #eef1f5 !important;
    color: var(--text-slate) !important;
}

/* Keep dark-blue buttons readable when disabled */
.w3-teal:disabled,
.w3-button.w3-teal:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
