/* Isotrax Support Center — Modern Theme */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --primary: #7C3AED;
    --primary-light: #8B5CF6;
    --primary-dark: #6D28D9;
    --primary-50: #F5F3FF;
    --primary-100: #EDE9FE;
    --primary-200: #DDD6FE;
    --gradient: linear-gradient(135deg, #7C3AED 0%, #6366F1 50%, #3B82F6 100%);
    --gradient-subtle: linear-gradient(135deg, #F5F3FF 0%, #EEF2FF 50%, #F0F9FF 100%);
    --surface: #ffffff;
    --bg: #F8FAFC;
    --text: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 50px -12px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Global & Typography
   ======================================== */
body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 8px;
    transition: var(--transition);
    letter-spacing: 0.01em;
}
.btn-primary {
    background: var(--gradient);
    border: none;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}
.btn-primary:hover {
    background: var(--gradient);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.3);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary-200);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}
.text-primary {
    color: var(--primary) !important;
}

/* ========================================
   Navbar
   ======================================== */
.navbar-main {
    background: #1a1a2e !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    border-bottom: none !important;
    padding: 0.5rem 0;
}
.navbar-main .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
    color: #FFFFFF;
    text-decoration: none;
}
.navbar-main .navbar-brand .brand-icon {
    width: 34px;
    height: 34px;
    background: var(--gradient);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #FFFFFF;
    flex-shrink: 0;
}
.navbar-main .navbar-brand .brand-text {
    font-weight: 700;
    font-size: 1.1rem;
}
nav.navbar-main .nav-link {
    font-weight: 600 !important;
    font-size: 0.875rem !important;
    letter-spacing: 0.01em !important;
    padding: 0.45rem 0.9rem !important;
    border-radius: 8px;
    transition: var(--transition);
    margin: 0 2px;
    color: rgba(255,255,255,0.65) !important;
}
nav.navbar-main .nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: #FFFFFF !important;
}
nav.navbar-main .nav-link.active {
    color: #FFFFFF !important;
    background: var(--gradient);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}
.navbar-main .dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    margin-top: 0.5rem;
}
.navbar-main .dropdown-item {
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
}
.navbar-main .dropdown-item:hover {
    background: var(--primary-50);
    color: var(--primary);
}

/* ========================================
   Cards
   ======================================== */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}
.card:hover {
    box-shadow: var(--shadow);
}
.card-header {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 1rem 1.25rem;
}
.card-header h6 {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

/* ========================================
   Login Page
   ======================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F0B1A 0%, #1A1033 30%, #1E1145 60%, #0D1B2A 100%);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(124, 58, 237, 0.12) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    animation: loginPulse 15s ease-in-out infinite;
}
@keyframes loginPulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.05) rotate(3deg); }
}
.login-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
    position: relative;
    z-index: 1;
    animation: loginSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes loginSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-card .form-control {
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--border);
    transition: var(--transition);
}
.login-card .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}
.login-card .input-group-text {
    border-radius: 10px 0 0 10px;
    background: var(--primary-50);
    border: 1.5px solid var(--border);
    border-right: none;
    color: var(--primary);
}
.login-card .btn-primary {
    padding: 0.7rem;
    font-size: 1rem;
    border-radius: 10px;
}

/* ========================================
   Badges — Status
   ======================================== */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.7em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}
.badge-new {
    background: linear-gradient(135deg, #64748B, #94A3B8);
    color: #fff;
}
.badge-open {
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    color: #fff;
}
.badge-in_progress, .badge-in-progress {
    background: linear-gradient(135deg, #EA580C, #F97316);
    color: #fff;
}
.badge-resolved {
    background: linear-gradient(135deg, #059669, #10B981);
    color: #fff;
}
.badge-closed {
    background: linear-gradient(135deg, #94A3B8, #CBD5E1);
    color: #475569;
}

/* Badges — Priority */
.badge-low {
    background: #F1F5F9;
    color: #64748B;
    border: 1px solid #E2E8F0;
}
.badge-medium {
    background: linear-gradient(135deg, #06B6D4, #22D3EE);
    color: #fff;
}
.badge-high {
    background: linear-gradient(135deg, #EA580C, #FB923C);
    color: #fff;
}
.badge-critical {
    background: linear-gradient(135deg, #DC2626, #EF4444);
    color: #fff;
    animation: criticalPulse 2s ease-in-out infinite;
}
@keyframes criticalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* Badges — Lead Status */
.badge-contacted {
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    color: #fff;
}
.badge-qualified {
    background: linear-gradient(135deg, #7C3AED, #A78BFA);
    color: #fff;
}
.badge-proposal_sent, .badge-proposal-sent {
    background: linear-gradient(135deg, #EA580C, #F97316);
    color: #fff;
}
.badge-won {
    background: linear-gradient(135deg, #059669, #10B981);
    color: #fff;
}
.badge-lost {
    background: linear-gradient(135deg, #94A3B8, #CBD5E1);
    color: #475569;
}

/* Badges — Lead Type */
.badge-demo_request, .badge-demo-request {
    background: linear-gradient(135deg, #7C3AED, #A78BFA);
    color: #fff;
}
.badge-contact {
    background: linear-gradient(135deg, #2563EB, #60A5FA);
    color: #fff;
}
.badge-sales_inquiry, .badge-sales-inquiry {
    background: linear-gradient(135deg, #059669, #34D399);
    color: #fff;
}

/* Badges — Category */
.badge-bug {
    background: linear-gradient(135deg, #DC2626, #F87171);
    color: #fff;
}
.badge-feature_request, .badge-feature-request {
    background: linear-gradient(135deg, #7C3AED, #A78BFA);
    color: #fff;
}
.badge-question {
    background: linear-gradient(135deg, #2563EB, #60A5FA);
    color: #fff;
}
.badge-support {
    background: linear-gradient(135deg, #0891B2, #22D3EE);
    color: #fff;
}
.badge-automated_error, .badge-automated-error {
    background: linear-gradient(135deg, #B91C1C, #EF4444);
    color: #fff;
}
.badge-other {
    background: #F1F5F9;
    color: #64748B;
    border: 1px solid #E2E8F0;
}

/* ========================================
   Dashboard Table
   ======================================== */
.ticket-table {
    font-size: 0.875rem;
}
.ticket-table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    padding: 0.85rem 1rem;
    white-space: nowrap;
}
.ticket-table td {
    vertical-align: middle;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #F1F5F9;
}
.ticket-table .ticket-number {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    background: var(--primary-50);
    padding: 0.2em 0.5em;
    border-radius: 6px;
    transition: var(--transition);
}
.ticket-table .ticket-number:hover {
    background: var(--primary-100);
    color: var(--primary-dark);
    text-decoration: none;
}
.ticket-table tbody tr {
    cursor: pointer;
    transition: var(--transition);
}
.ticket-table tbody tr:hover {
    background-color: var(--primary-50) !important;
}

/* ========================================
   Nav Tabs (Time Admin, etc.)
   ======================================== */
.nav-tabs {
    border-bottom: 2px solid var(--border);
}
.nav-tabs .nav-link {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.85rem 1rem;
    transition: var(--transition);
    border-radius: 0;
}
.nav-tabs .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary-200);
    background: var(--primary-50);
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 700;
}
.nav-tabs .nav-link:focus {
    box-shadow: none;
}

/* ========================================
   Filter Bar
   ======================================== */
.filter-bar .form-select,
.filter-bar .form-control {
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    transition: var(--transition);
}
.filter-bar .form-select:focus,
.filter-bar .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.filter-bar .form-label {
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ========================================
   Form Controls (Global)
   ======================================== */
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid var(--border);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
}

/* ========================================
   Pagination
   ======================================== */
.pagination .page-link {
    color: var(--primary);
    border: 1.5px solid var(--border);
    border-radius: 8px !important;
    margin: 0 2px;
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition);
}
.pagination .page-link:hover {
    background: var(--primary-50);
    border-color: var(--primary-200);
    color: var(--primary-dark);
}
.pagination .page-item.active .page-link {
    background: var(--gradient);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

/* ========================================
   Ticket Detail
   ======================================== */
.ticket-sidebar {
    position: sticky;
    top: 80px;
}

/* Comment thread — chat-style layout */
.comment-thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.comment-thread .comment-item {
    padding: 0.85rem 1rem;
    margin-bottom: 0;
    max-width: 80%;
    position: relative;
    transition: var(--transition);
}
.comment-thread .comment-item .comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    gap: 0.75rem;
}
.comment-thread .comment-item .comment-body {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 0.9rem;
}

/* Customer comments — left aligned, blue */
.comment-thread .comment-item.is-customer {
    align-self: flex-start;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 4px 12px 12px 12px;
}
.comment-thread .comment-item.is-customer:hover {
    background: #DBEAFE;
}
.comment-thread .comment-item.is-customer .comment-author {
    color: #1D4ED8;
    font-weight: 600;
}

/* Staff comments — right aligned, purple */
.comment-thread .comment-item.is-staff {
    align-self: flex-end;
    background: var(--primary-50);
    border: 1px solid #DDD6FE;
    border-radius: 12px 4px 12px 12px;
}
.comment-thread .comment-item.is-staff:hover {
    background: var(--primary-100);
}
.comment-thread .comment-item.is-staff .comment-author {
    color: var(--primary);
    font-weight: 600;
}

/* System comments — centered, neutral */
.comment-thread .comment-item.is-system {
    align-self: center;
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    max-width: 90%;
    font-style: italic;
}
.comment-thread .comment-item.is-system:hover {
    background: #E5E7EB;
}
.comment-thread .comment-item.is-system .comment-author {
    color: #6B7280;
    font-weight: 600;
}

/* Internal note — dashed border overlay */
.comment-thread .comment-item.is-internal {
    border-style: dashed !important;
    opacity: 0.8;
}

/* Status history timeline */
.status-timeline .timeline-item {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 1.25rem;
    border-left: 2px solid var(--border);
    margin-left: 0.5rem;
}
.status-timeline .timeline-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}
.status-timeline .timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gradient);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* ========================================
   Modals
   ======================================== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
}
.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.1rem;
}
.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
}

/* ========================================
   Alert Overrides
   ======================================== */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
}
.alert-danger {
    background: #FEF2F2;
    color: #991B1B;
    border-left: 4px solid #EF4444;
}
.alert-success {
    background: #F0FDF4;
    color: #166534;
    border-left: 4px solid #22C55E;
}

/* ========================================
   User Management
   ======================================== */
.ticket-table .table-secondary td {
    opacity: 0.6;
}
.ticket-table .table-secondary:hover td {
    opacity: 0.85;
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* ========================================
   Page transition
   ======================================== */
main {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Breadcrumb
   ======================================== */
.breadcrumb {
    font-size: 0.85rem;
}
.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.breadcrumb a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    .ticket-table {
        font-size: 0.8rem;
    }
    .login-card {
        padding: 2rem 1.5rem;
    }
}

/* ========================================
   Statistics Dashboard
   ======================================== */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
#stats_content .card {
    border-radius: var(--radius-lg);
}
#stats_content .card-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
#stats_content .card-header h6 {
    font-size: 0.85rem;
    font-weight: 600;
}
