/**
 * HelpDesk Pro - Modern Ticket System Styles
 * Inspired by FreshDesk
 */

/* ===== CSS Variables ===== */
:root {
    /* Primary Colors */
    --primary: #0052cc;
    --primary-dark: #003d99;
    --primary-light: #4c9aff;
    --primary-bg: #f0f7ff;
    
    /* Secondary Colors */
    --secondary: #6554c0;
    --secondary-dark: #403294;
    --secondary-light: #998dd9;
    
    /* Status Colors */
    --success: #00875a;
    --success-bg: #e3fcef;
    --warning: #ff991f;
    --warning-bg: #fffae6;
    --danger: #de350b;
    --danger-bg: #ffebe6;
    --info: #0065ff;
    --info-bg: #deebff;
    
    /* Priority Colors */
    --priority-low: #36b37e;
    --priority-medium: #ffab00;
    --priority-high: #ff5630;
    --priority-urgent: #bf2600;
    
    /* Status Colors */
    --status-open: #0065ff;
    --status-pending: #ffab00;
    --status-resolved: #36b37e;
    --status-closed: #6b778c;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #fafbfc;
    --gray-100: #f4f5f7;
    --gray-200: #ebecf0;
    --gray-300: #dfe1e6;
    --gray-400: #c1c7d0;
    --gray-500: #97a0af;
    --gray-600: #6b778c;
    --gray-700: #505f79;
    --gray-800: #344563;
    --gray-900: #172b4d;
    --black: #091e42;
    
    /* Typography */
    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(9, 30, 66, 0.08);
    --shadow-md: 0 4px 8px -2px rgba(9, 30, 66, 0.1), 0 0 1px rgba(9, 30, 66, 0.31);
    --shadow-lg: 0 8px 16px -4px rgba(9, 30, 66, 0.15), 0 0 1px rgba(9, 30, 66, 0.31);
    --shadow-xl: 0 12px 24px -6px rgba(9, 30, 66, 0.2), 0 0 1px rgba(9, 30, 66, 0.31);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --content-max-width: 1400px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-900);
    background-color: var(--gray-100);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

p {
    margin-bottom: var(--spacing-md);
}

/* ===== Layout Components ===== */

/* Auth Layout (Login/Register/Setup) */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: var(--spacing-lg);
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-2xl);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.auth-logo h1 {
    font-size: 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo-img {
    max-height: 64px;
    max-width: 80%;
    object-fit: contain;
    margin-bottom: 4px;
}

.auth-logo .subtitle {
    color: var(--gray-600);
    font-size: 14px;
    margin-top: var(--spacing-xs);
}

.auth-title {
    font-size: 24px;
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

/* Main Layout */
.main-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.sidebar-logo-text {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-logo-img {
    max-height: 38px;
    max-width: 100%;
    object-fit: contain;
}

.sidebar-nav {
    padding: var(--spacing-md) 0;
}

.nav-section {
    margin-bottom: var(--spacing-md);
}

.nav-section-title {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--gray-400);
    transition: all var(--transition-fast);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left-color: var(--primary-light);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item-badge {
    margin-left: auto;
    background: var(--primary);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.header-search {
    position: relative;
}

.header-search input {
    width: 280px;
    padding: var(--spacing-sm) var(--spacing-md);
    padding-left: 40px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.header-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu-toggle:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar.user-avatar-img {
    background: var(--gray-100);
    padding: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-avatar-preview {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--spacing-md);
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--spacing-sm);
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
    z-index: 1000;
}

.user-menu.open .user-menu-dropdown {
    display: block;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--gray-700);
    transition: all var(--transition-fast);
}

.user-menu-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.user-menu-divider {
    height: 1px;
    background: var(--gray-200);
    margin: var(--spacing-xs) 0;
}

/* Page Content */
.page-content {
    padding: var(--spacing-lg);
    max-width: var(--content-max-width);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: all var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-md);
    font-size: 24px;
}

.stat-card-icon.blue {
    background: var(--info-bg);
    color: var(--info);
}

.stat-card-icon.orange {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-card-icon.green {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card-icon.gray {
    background: var(--gray-200);
    color: var(--gray-600);
}

.stat-card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-card-label {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: var(--spacing-xs);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--spacing-xs);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-control::placeholder {
    color: var(--gray-500);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b778c' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.762-3.762L10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: var(--spacing-xs);
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: var(--spacing-xs);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
    color: var(--gray-900);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: #006644;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: #bf2600;
}

.btn-warning {
    background: #ff8b00;
    color: var(--white);
}

.btn-warning:hover:not(:disabled) {
    background: #e07600;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-link {
    background: transparent;
    color: var(--primary);
    padding: 0;
}

.btn-link:hover {
    color: var(--primary-dark);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: var(--spacing-sm);
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    background: var(--gray-50);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-striped tbody tr:nth-child(even) {
    background: var(--gray-50);
}

/* ===== Tickets List ===== */
.ticket-list {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.ticket-list-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.ticket-list-filters {
    display: flex;
    gap: var(--spacing-sm);
}

.ticket-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.ticket-item:hover {
    background: var(--gray-50);
}

.ticket-item:last-child {
    border-bottom: none;
}

.ticket-checkbox {
    padding-top: 2px;
}

.ticket-priority-indicator {
    width: 4px;
    height: 100%;
    min-height: 48px;
    border-radius: 2px;
}

.ticket-priority-indicator.low { background: var(--priority-low); }
.ticket-priority-indicator.medium { background: var(--priority-medium); }
.ticket-priority-indicator.high { background: var(--priority-high); }
.ticket-priority-indicator.urgent { background: var(--priority-urgent); }

.ticket-main {
    flex: 1;
    min-width: 0;
}

.ticket-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.ticket-number {
    font-size: 12px;
    color: var(--gray-600);
    font-weight: 500;
}

.ticket-subject {
    font-weight: 500;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticket-subject:hover {
    color: var(--primary);
}

.ticket-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: 12px;
    color: var(--gray-600);
}

.ticket-customer {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.ticket-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }

/* Priority Badges */
.priority-low { background: #e3fcef; color: #006644; }
.priority-medium { background: #fffae6; color: #ff991f; }
.priority-high { background: #ffebe6; color: #bf2600; }
.priority-urgent { background: #ffebe6; color: #bf2600; font-weight: 700; }

/* Status Badges */
.status-open { background: #deebff; color: #0052cc; }
.status-pending { background: #fffae6; color: #ff8b00; }
.status-resolved { background: #e3fcef; color: #006644; }
.status-closed { background: var(--gray-200); color: var(--gray-600); }

/* ===== Ticket Detail ===== */
.ticket-detail {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--spacing-lg);
}

.ticket-detail-main {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.ticket-detail-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
}

.ticket-detail-title {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.ticket-detail-subject {
    font-size: 20px;
    font-weight: 600;
}

.ticket-detail-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    font-size: 13px;
    color: var(--gray-600);
}

.ticket-messages {
    padding: var(--spacing-lg);
}

.ticket-message {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.ticket-message:last-child {
    margin-bottom: 0;
}

.ticket-message-avatar {
    flex-shrink: 0;
}

.ticket-message-content {
    flex: 1;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.ticket-message.staff .ticket-message-content {
    background: var(--primary-bg);
}

.ticket-message.internal .ticket-message-content {
    background: #fffae6;
    border: 1px dashed var(--warning);
}

.ticket-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.ticket-message-author {
    font-weight: 600;
    color: var(--gray-900);
}

.ticket-message-time {
    font-size: 12px;
    color: var(--gray-600);
}

.ticket-message-body {
    color: var(--gray-800);
    line-height: 1.6;
    white-space: pre-wrap;
}

.ticket-reply-form {
    border-top: 1px solid var(--gray-200);
    padding: var(--spacing-lg);
}

.reply-tabs {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.reply-tab {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.reply-tab.active {
    background: var(--primary);
    color: var(--white);
}

.reply-tab:hover:not(.active) {
    background: var(--gray-200);
}

/* Ticket Sidebar */
.ticket-sidebar {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    height: fit-content;
}

.ticket-sidebar-section {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--gray-200);
}

.ticket-sidebar-section:last-child {
    border-bottom: none;
}

.ticket-sidebar-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    margin-bottom: var(--spacing-sm);
}

.silent-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--gray-600);
    cursor: pointer;
    user-select: none;
}

.silent-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.silent-toggle:hover {
    color: var(--gray-800);
}

.ticket-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
}

.ticket-sidebar-label {
    font-size: 13px;
    color: var(--gray-600);
}

.ticket-sidebar-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-900);
}

/* ===== Alerts ===== */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    color: #946600;
    border: 1px solid var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid var(--info);
}

/* ===== Setup Wizard ===== */
.setup-wizard {
    max-width: 600px;
}

.setup-steps {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-xl);
}

.setup-step {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 14px;
    color: var(--gray-500);
}

.setup-step.active {
    color: var(--primary);
    font-weight: 500;
}

.setup-step.completed {
    color: var(--success);
}

.setup-step-number {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.setup-step.active .setup-step-number {
    background: var(--primary);
    color: var(--white);
}

.setup-step.completed .setup-step-number {
    background: var(--success);
    color: var(--white);
}

.setup-step-connector {
    width: 40px;
    height: 2px;
    background: var(--gray-200);
}

.setup-step.completed + .setup-step-connector,
.setup-step.completed ~ .setup-step-connector {
    background: var(--success);
}

/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
}

.empty-state-icon {
    font-size: 64px;
    color: var(--gray-400);
    margin-bottom: var(--spacing-md);
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--spacing-sm);
}

.empty-state-text {
    color: var(--gray-600);
    margin-bottom: var(--spacing-lg);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(9, 30, 66, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-md);
}

.pagination-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-700);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Language Switcher ===== */
.lang-switcher {
    display: flex;
    gap: var(--spacing-xs);
}

.lang-btn {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.lang-btn:hover:not(.active) {
    background: var(--gray-100);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .ticket-detail {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .header-search {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .ticket-list-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ticket-list-filters {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-card {
        padding: var(--spacing-lg);
    }
}

/* ===== Export / Import ===== */
.export-toolbar {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    animation: fadeIn 0.15s ease;
}

.export-checkbox-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.export-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.import-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 2px solid var(--gray-200);
}

.import-tab {
    padding: 10px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.import-tab:hover {
    color: var(--gray-900);
}

.import-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.import-panel {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.import-instructions {
    line-height: 1.7;
}

.import-instructions h4 {
    margin-bottom: var(--spacing-sm);
}

.import-instructions p {
    color: var(--gray-700);
    margin-bottom: var(--spacing-md);
}

.import-columns-info {
    margin-top: var(--spacing-md);
}

.import-columns-info h5 {
    margin-bottom: var(--spacing-sm);
}

.import-columns-info code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--primary);
}

/* ===== Canned Responses ===== */

/* Management page list */
.canned-list {
    border-top: 1px solid var(--gray-200);
}

.canned-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    transition: background var(--transition-fast);
}

.canned-item:hover {
    background: var(--gray-50);
}

.canned-item:last-child {
    border-bottom: none;
}

.canned-item-main {
    flex: 1;
    min-width: 0;
}

.canned-item-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.canned-item-preview {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
    margin-bottom: 6px;
    white-space: pre-line;
}

.canned-item-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 12px;
    color: var(--gray-500);
}

.canned-item-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

/* Canned response picker in ticket reply */
.canned-picker {
    position: relative;
    margin-bottom: var(--spacing-md);
}

.canned-picker-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.canned-picker-toggle:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

.canned-picker-arrow {
    font-size: 10px;
    transition: transform var(--transition-fast);
}

.canned-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 340px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.canned-picker-dropdown.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

.canned-picker-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition-fast);
}

.canned-picker-item:hover {
    background: var(--gray-50);
}

.canned-picker-item:last-child {
    border-bottom: none;
}

.canned-picker-item-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.canned-picker-item-preview {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Tags ===== */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
}

.tag-badge-sm {
    padding: 1px 8px;
    font-size: 10px;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 2px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.tag-remove:hover {
    opacity: 1;
}

.tag-add-section {
    position: relative;
}

.tag-input-wrapper {
    position: relative;
}

.tag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}

.tag-dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition-fast);
}

.tag-dropdown-item:hover {
    background: var(--gray-100);
}

.tag-dropdown-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tag-dropdown-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.tag-create-item {
    color: var(--primary);
    border-top: 1px solid var(--gray-200);
}

.tag-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--gray-600); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing-md); }

.hidden { display: none !important; }

/* Database Settings */
.db-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius);
    font-size: 13px;
}

.db-status-label {
    font-weight: 500;
    color: var(--gray-700);
}

.db-driver-radios {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.db-radio-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s;
}

.db-radio-label:hover {
    border-color: var(--gray-400);
}

.db-radio-label input[type="radio"] {
    margin-top: 2px;
}

.db-radio-label span:first-of-type {
    font-weight: 500;
}

.db-radio-label .form-hint {
    display: block;
    margin-top: 2px;
}

.db-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.db-action-item {
    text-align: center;
}

.db-action-item .form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
}

/* Login Background Preview */
.logo-preview {
    display: inline-block;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.logo-preview img {
    max-height: 64px;
    max-width: 240px;
    object-fit: contain;
    display: block;
}

.login-bg-preview {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    max-height: 160px;
}

.login-bg-preview img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

/* ========== Attachment Styles ========== */

.message-attachments {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.attachments-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-right: 4px;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--gray-700);
    text-decoration: none;
    transition: all 0.15s ease;
}

.attachment-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.attachment-icon {
    font-size: 14px;
    line-height: 1;
}

.attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    color: var(--gray-400);
    font-size: 11px;
    white-space: nowrap;
}

.attachment-input {
    margin-top: 8px;
}

.attachment-input label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--gray-600);
}

.attachment-input input[type="file"] {
    padding: 8px;
    font-size: 13px;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
    background: var(--gray-50);
    cursor: pointer;
}

.attachment-input input[type="file"]:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.attachment-input .form-hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--gray-400);
}

/* ========== Delete Confirmation Modal ========== */

.confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(9, 30, 66, 0.54);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.confirm-modal-overlay.visible {
    display: flex;
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    padding: 28px 32px;
}

.modal-box h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: var(--gray-900);
}

.modal-box p {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: var(--gray-500);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========== Spam & Blocking ========== */

.spam-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.spam-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--gray-200);
}

.spam-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.spam-tab:hover {
    color: var(--gray-700);
}

.spam-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.spam-section {
    margin-bottom: 24px;
}

.spam-ticket-item {
    opacity: 0.85;
}

.spam-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.spam-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .spam-grid {
        grid-template-columns: 1fr;
    }
}

.spam-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.spam-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.spam-card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.spam-add-form {
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.blocked-list {
    max-height: 400px;
    overflow-y: auto;
}

.blocked-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--gray-100);
    gap: 12px;
}

.blocked-item:last-child {
    border-bottom: none;
}

.blocked-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.blocked-info strong {
    font-size: 13px;
    word-break: break-all;
}

.blocked-info small {
    font-size: 11px;
}

.block-user-form {
    margin-top: 8px;
}

.block-domain-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--gray-600);
    cursor: pointer;
}

.block-domain-toggle input[type="checkbox"] {
    margin: 0;
}

.blocked-indicator {
    font-size: 12px;
    font-weight: 600;
    color: #ff8b00;
    padding: 6px 0;
}

.badge-spam {
    background: #ff8b00 !important;
}

/* ========== Activity Log ========== */

.activity-filters {
    margin-bottom: 20px;
}

.activity-filter-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.activity-filter-form .filter-group {
    flex: 1;
    min-width: 150px;
    max-width: 250px;
}

.activity-filter-form .filter-group select,
.activity-filter-form .filter-group input {
    width: 100%;
}

.activity-log-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

.activity-log-table {
    width: 100%;
    border-collapse: collapse;
}

.activity-log-table thead th {
    background: #f9fafb;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.activity-log-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.activity-log-table tbody tr:last-child {
    border-bottom: none;
}

.activity-log-table tbody tr:hover {
    background: #f9fafb;
}

.activity-log-table td {
    padding: 12px 16px;
    font-size: 14px;
    vertical-align: middle;
}

.activity-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-action-blue { background: #dbeafe; color: #1e40af; }
.badge-action-green { background: #dcfce7; color: #166534; }
.badge-action-red { background: #fee2e2; color: #991b1b; }
.badge-action-orange { background: #ffedd5; color: #9a3412; }
.badge-action-purple { background: #ede9fe; color: #5b21b6; }
.badge-action-teal { background: #ccfbf1; color: #115e59; }
.badge-action-gray { background: #f3f4f6; color: #374151; }

.activity-details {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4b5563;
}

.activity-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.activity-role {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.activity-role.badge-admin {
    background: #fee2e2;
    color: #991b1b;
}

.activity-role.badge-technician {
    background: #dbeafe;
    color: #1e40af;
}

.activity-ip {
    font-family: monospace;
    font-size: 13px;
    color: #9ca3af;
}

.activity-date {
    white-space: nowrap;
    color: #6b7280;
    font-size: 13px;
}

@media (max-width: 768px) {
    .activity-filter-form {
        flex-direction: column;
    }

    .activity-filter-form .filter-group {
        max-width: 100%;
    }

    .activity-log-table td,
    .activity-log-table th {
        padding: 8px 10px;
        font-size: 13px;
    }

    .activity-details {
        max-width: 150px;
    }
}

/* Toggle Switches */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}
.toggle-switch-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.toggle-switch-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ===== Live Chat Widget ===== */
.chat-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--primary, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.35);
    transition: transform .12s ease, box-shadow .12s ease;
}
.chat-fab:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(59, 130, 246, 0.45);
}
.chat-fab-icon { font-size: 18px; line-height: 1; }
.chat-fab-badge {
    background: var(--danger, #ef4444);
    color: #fff;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.chat-panel {
    position: fixed;
    right: 24px;
    bottom: 80px;
    z-index: 1090;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-panel[hidden] { display: none !important; }

.chat-panel-header {
    background: var(--primary, #3b82f6);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.chat-panel-title {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.chat-panel-title small {
    opacity: 0.85;
    font-size: 11px;
    margin-top: 2px;
}
.chat-panel-close {
    background: transparent;
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.chat-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-50, #f9fafb);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-empty {
    text-align: center;
    color: var(--gray-500, #6b7280);
    font-size: 13px;
    padding: 20px 0;
}

.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.chat-msg-mine {
    flex-direction: row-reverse;
}
.chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-700, #374151);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}
.chat-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.chat-msg-content {
    max-width: 75%;
    min-width: 0;
}
.chat-msg-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--gray-500, #6b7280);
    margin-bottom: 2px;
    flex-wrap: wrap;
}
.chat-msg-mine .chat-msg-head { justify-content: flex-end; }
.chat-msg-name { font-weight: 600; color: var(--gray-700, #374151); }
.chat-msg-role {
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-700, #374151);
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 10px;
    text-transform: capitalize;
}
.chat-msg-staff .chat-msg-role {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary, #3b82f6);
}
.chat-msg-internal-badge {
    background: rgba(234, 179, 8, 0.2) !important;
    color: #92400e !important;
}
.chat-msg-time { color: var(--gray-400, #9ca3af); }
.chat-msg-bubble {
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 14px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--gray-800, #1f2937);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.chat-msg-mine .chat-msg-bubble {
    background: var(--primary, #3b82f6);
    color: #fff;
    border-color: var(--primary, #3b82f6);
    border-bottom-right-radius: 4px;
}
.chat-msg-mine .chat-msg-bubble a {
    color: #fff;
    text-decoration: underline;
}
.chat-msg-staff:not(.chat-msg-mine) .chat-msg-bubble {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.chat-msg-internal .chat-msg-bubble {
    background: #fffbeb !important;
    border-color: #fde68a !important;
    color: #78350f !important;
}

.chat-panel-input {
    border-top: 1px solid var(--gray-200, #e5e7eb);
    padding: 10px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
}
.chat-panel-input textarea {
    flex: 1;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 10px;
    padding: 8px 10px;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    outline: none;
    max-height: 120px;
}
.chat-panel-input textarea:focus {
    border-color: var(--primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.chat-panel-input button {
    padding: 8px 14px;
}
.chat-panel-notice {
    padding: 8px 12px;
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-600, #4b5563);
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}

@media (max-width: 600px) {
    .chat-panel {
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 70vh;
        border-radius: 14px 14px 0 0;
    }
    .chat-fab { right: 12px; bottom: 12px; }
    .chat-fab-label { display: none; }
}
