/**
 * CW Ticket - Premium CSS Design System
 * Unified CSS property variables, Light & Dark themes, and responsive wrapping grids.
 */

/* ==========================================================================
   1. Theme System (HSL Configs)
   ========================================================================== */
:root[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-secondary: #0d1222;
    --bg-body-gradient: linear-gradient(135deg, #090d16 0%, #0d122b 50%, #1c092a 100%);
    --bg-glass: rgba(19, 26, 46, 0.55);
    --bg-glass-hover: rgba(30, 41, 59, 0.75);
    --border-glass: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #a855f7; /* Purple */
    --accent-secondary: #3b82f6; /* Blue */
    --accent-success: #10b981; /* Green */
    --accent-warning: #f59e0b; /* Yellow */
    --accent-danger: #ef4444; /* Red */
    
    --glow-primary: rgba(168, 85, 247, 0.2);
    --shadow-main: rgba(0, 0, 0, 0.5);
    --card-accent: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    --input-bg: rgba(15, 23, 42, 0.6);
}

:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-body-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-glass-hover: rgba(255, 255, 255, 0.95);
    --border-glass: rgba(15, 23, 42, 0.12);
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --accent-primary: #7c3aed;
    --accent-secondary: #2563eb;
    --accent-success: #059669;
    --accent-warning: #d97706;
    --accent-danger: #dc2626;
    
    --glow-primary: rgba(124, 58, 237, 0.15);
    --shadow-main: rgba(15, 23, 42, 0.1);
    --card-accent: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    --input-bg: #ffffff;
}

/* ==========================================================================
   2. Reset & General Typography
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Client submit body framework */
.client-portal-body {
    background: var(--bg-body-gradient) !important;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    transition: background 0.4s ease;
}

a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}
a:hover {
    color: var(--accent-primary);
}

/* ==========================================================================
   3. Framework Layout System (Dashboard)
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Navigation */
.app-sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--card-accent);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px var(--glow-primary);
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background-color: var(--border-glass);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--card-accent);
    color: white;
    box-shadow: 0 4px 15px var(--glow-primary);
}

.nav-icon {
    font-size: 1.2rem;
}

/* Content Area */
.app-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title h2 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Theme Toggle */
.theme-toggle-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}
.theme-toggle-btn:hover {
    transform: scale(1.05);
    background-color: var(--bg-glass-hover);
}

/* Profile Badge */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem 0.4rem 0.4rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 30px;
}

.profile-avatar {
    width: 32px;
    height: 32px;
    background: var(--card-accent);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    color: white;
    font-size: 0.85rem;
}

.profile-info {
    font-size: 0.85rem;
    text-align: left;
}

.profile-name {
    font-weight: 600;
    color: var(--text-primary);
}

.profile-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* ==========================================================================
   4. Glassmorphism Card System
   ========================================================================== */
.card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px var(--shadow-main);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card:hover {
    background-color: var(--bg-glass-hover);
}

/* Dashboard Widget Grids */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.widget-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.widget-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.widget-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.widget-change {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.change-up { color: var(--accent-success); }
.change-down { color: var(--accent-danger); }

/* ==========================================================================
   5. Interactive Live Time Tracker Widgets
   ========================================================================== */
.timer-container {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.12) 0%, rgba(59, 130, 246, 0.12) 100%);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    backdrop-filter: blur(12px);
    color: var(--text-primary);
}

.timer-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
}

.timer-ticket-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.timer-clock {
    font-family: monospace;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--glow-primary);
}

.timer-actions {
    display: flex;
    gap: 0.75rem;
}

/* Button UI Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--card-accent);
    color: white !important;
    box-shadow: 0 4px 12px var(--glow-primary);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--glow-primary);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: var(--border-glass);
}

.btn-danger {
    background-color: var(--accent-danger);
    color: white;
}
.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* ==========================================================================
   6. UI Tables & Metrics Grids
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.65rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-open {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-in_progress, .badge-progress {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.25);
}

.badge-resolved {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-closed {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.25);
}

/* Priorities */
.badge-priority-low { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); }
.badge-priority-medium { background: rgba(245, 158, 11, 0.1); color: var(--accent-warning); }
.badge-priority-high { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.badge-priority-urgent { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); font-weight: 700; }

/* ==========================================================================
   7. Form Inputs & Control Structures
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-group-full {
    grid-column: span 2;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--glow-primary);
    background: var(--input-bg);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

/* Responsive Radio buttons wrapper */
.radio-flex-container {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

@media (max-width: 600px) {
    .radio-flex-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ==========================================================================
   8. Ticket Detail & Timeline Visuals
   ========================================================================== */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

/* Timeline Components */
.timeline {
    position: relative;
    padding-left: 2rem;
    margin-top: 1.5rem;
    text-align: left;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background-color: var(--border-glass);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-dot {
    position: absolute;
    left: -2rem;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 3px solid var(--accent-secondary);
}

.timeline-dot.system { border-color: var(--accent-primary); }
.timeline-dot.status { border-color: var(--accent-warning); }
.timeline-dot.complete { border-color: var(--accent-success); }

.timeline-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.timeline-body {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* SLA Meter */
.sla-progress-container {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.sla-progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.sla-ok { background-color: var(--accent-success); }
.sla-warning { background-color: var(--accent-warning); }
.sla-critical { background-color: var(--accent-danger); }

/* Private Staff Notes Visual indicator */
.reply-card {
    margin-bottom: 1.5rem;
    text-align: left;
}

.reply-card.internal-note {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1px dashed rgba(245, 158, 11, 0.4);
}

.internal-note-badge {
    background-color: var(--accent-warning);
    color: #0b0f19;
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
}

/* ==========================================================================
   9. Auth / Gateway Panels
   ========================================================================== */
.gateway-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.gateway-card {
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
}

/* ==========================================================================
   10. Modals & Overlays
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    width: 100%;
    max-width: 550px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ==========================================================================
   11. Notification Toasts
   ========================================================================== */
.toast-feed {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    animation: toastSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes toastSlide {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   12. Responsive Adjustments (Media Queries)
   ========================================================================== */
@media (max-width: 1024px) {
    .ticket-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    
    .app-sidebar.show {
        transform: translateX(0);
    }
    
    .app-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group-full {
        grid-column: span 1;
    }
}