:root {
    /* Colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f3f4f6;
    --bg-surface: #ffffff;
    --text-main: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;

    /* Status Colors */
    --status-new-bg: #dbeafe;
    --status-new-text: #1e40af;
    --status-open-bg: #e0e7ff;
    --status-open-text: #3730a3;
    --status-pending-bg: #fef3c7;
    --status-pending-text: #92400e;
    --status-solved-bg: #d1fae5;
    --status-solved-text: #065f46;
    --status-closed-bg: #f3f4f6;
    --status-closed-text: #374151;

    /* Priority Colors */
    --priority-urgent: #ef4444;
    --priority-high: #f97316;
    --priority-normal: #3b82f6;
    --priority-low: #6b7280;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Layout */
    --sidebar-width: 240px;
    --header-height: 64px;
}

body.dark-mode {
    --bg-body: #111827;
    --bg-surface: #1f2937;
    --text-main: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --status-closed-bg: #374151;
    --status-closed-text: #d1d5db;
}

body.dark-mode .sidebar {
    border-right: 1px solid var(--border-color);
}

body.dark-mode .top-header {
    background-color: var(--bg-surface);
}

body.dark-mode .card {
    background-color: var(--bg-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-mode .form-control {
    background-color: #374151;
    border-color: #4b5563;
    color: white;
}

body.dark-mode .data-table tr:hover {
    background-color: #374151;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #1f2937;
    /* Dark sidebar */
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    font-weight: bold;
    font-size: 1.25rem;
    border-bottom: 1px solid #374151;
}

.nav-links {
    list-style: none;
    padding: var(--spacing-md) 0;
    flex: 1;
}

.nav-item {
    padding: 0;
    /* Reset padding for link */
    cursor: pointer;
    color: #d1d5db;
    transition: all 0.2s;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    color: inherit;
    text-decoration: none;
    width: 100%;
    height: 100%;
}

.nav-item:hover,
.nav-item.active {
    background-color: #374151;
    color: white;
}

.user-profile {
    padding: var(--spacing-md);
    border-top: 1px solid #374151;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
}

.avatar-xs {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #e5e7eb;
    color: #374151;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    margin-right: 6px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.action-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.9rem;
}

.action-btn:hover {
    background-color: var(--primary-hover);
}

.action-btn.secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.action-btn.secondary:hover {
    background-color: #f9fafb;
}

.action-btn.success {
    background-color: #10b981;
}

.action-btn.success:hover {
    background-color: #059669;
}

.action-btn.full-width {
    width: 100%;
}

.action-btn.small {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

/* Utility Classes */
.card {
    background: var(--bg-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.card.no-padding {
    padding: 0;
}

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

/* Status Badges */
.status-new {
    background-color: var(--status-new-bg);
    color: var(--status-new-text);
}

.status-open {
    background-color: var(--status-open-bg);
    color: var(--status-open-text);
}

.status-pending {
    background-color: var(--status-pending-bg);
    color: var(--status-pending-text);
}

.status-solved {
    background-color: var(--status-solved-bg);
    color: var(--status-solved-text);
}

.status-closed {
    background-color: var(--status-closed-bg);
    color: var(--status-closed-text);
}

/* Priority Indicators */
.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.priority-urgent {
    background-color: var(--priority-urgent);
}

.priority-high {
    background-color: var(--priority-high);
}

.priority-normal {
    background-color: var(--priority-normal);
}

.priority-low {
    background-color: var(--priority-low);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.data-table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:hover {
    background-color: #f9fafb;
    cursor: pointer;
}

/* Dashboard Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Dashboard Columns */
.dashboard-columns {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--spacing-xl);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-main);
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.form-actions.right {
    justify-content: flex-end;
}

/* Ticket Detail Layout */
.ticket-detail-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--spacing-xl);
    height: 100%;
}

.ticket-header {
    margin-bottom: var(--spacing-md);
}

.ticket-title {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
}

.ticket-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-view {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.comment-wrapper {
    display: flex;
    width: 100%;
}

.comment-wrapper.me {
    justify-content: flex-end;
}

.comment-wrapper.other {
    justify-content: flex-start;
}

.comment-bubble {
    max-width: 80%;
    padding: var(--spacing-md);
    border-radius: 12px;
    background: white;
    border: 1px solid var(--border-color);
}

.comment-wrapper.me .comment-bubble {
    background: #eff6ff;
    border-color: #dbeafe;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
    gap: 12px;
}

.comment-author {
    font-weight: 600;
}

.reply-box {
    background: #f9fafb;
    border-top: 1px solid var(--border-color);
}

.reply-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.right-actions {
    display: flex;
    gap: 8px;
}

/* Sidebar Widget */
.ticket-sidebar {
    background: var(--bg-surface);
    padding: var(--spacing-md);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    height: fit-content;
}

.property-group {
    margin-bottom: var(--spacing-lg);
}

.property-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.sla-widget {
    background: #f3f4f6;
    padding: 8px;
    border-radius: 6px;
}

.sla-text {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.sla-bar-bg {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.sla-bar-fill {
    height: 100%;
    border-radius: 3px;
}

/* Login Screen */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--primary-color);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    margin: 0 auto 1rem;
}

.user-select-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.user-option {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.user-option:hover {
    border-color: var(--primary-color);
}

.user-option.selected {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.user-details {
    margin-top: 0.5rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-option .avatar {
    margin: 0 auto;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Helpers */
.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-600 {
    color: #2563eb;
}

.bg-yellow-100 {
    background-color: #fef3c7;
}

.text-yellow-600 {
    color: #d97706;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

.text-gray-600 {
    color: #4b5563;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.text-red-600 {
    color: #dc2626;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.online {
    background-color: #10b981;
}

.status-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.status-item:last-child {
    border-bottom: none;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.15s;
}

.autocomplete-item:hover {
    background-color: #f3f4f6;
}

.autocomplete-item:active {
    background-color: #e5e7eb;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spinning {
    animation: spin 1s linear infinite;
}

/* Analytics Dashboard */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.report-header {
    margin-bottom: var(--spacing-lg);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.kpi-icon.blue {
    background-color: #e0e7ff;
    color: #4f46e5;
}

.kpi-icon.orange {
    background-color: #ffedd5;
    color: #f97316;
}

.kpi-icon.green {
    background-color: #dcfce7;
    color: #22c55e;
}

.kpi-icon.purple {
    background-color: #f3e8ff;
    color: #a855f7;
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-row {
    margin-bottom: 12px;
}

.stat-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.stat-value {
    font-weight: 600;
}

.progress-bg {
    height: 8px;
    background-color: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.progress-fill.primary {
    background-color: var(--primary-color);
}

.progress-fill.secondary {
    background-color: #8b5cf6;
}