
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazir', 'Tahoma', sans-serif;
}

:root {
    --bg-body: #f4f7fb;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --border: #e5e7eb;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --table-header: #f9fafb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --font-sm: 0.85rem;
    --font-base: 1rem;
    --error-color: #dc2626;
    --error-bg: #fee2e2;
}

body.theme-dark {
    --bg-body: #111827;
    --bg-card: #1f2937;
    --text-primary: #f3f4f6;
    --text-secondary: #d1d5db;
    --border: #374151;
    --primary: #a78bfa;
    --table-header: #374151;
}

body.theme-blue {
    --bg-body: #e0f2fe;
    --bg-card: #f0f9ff;
    --text-primary: #0c4a6e;
    --text-secondary: #075985;
    --border: #bae6fd;
    --primary: #0284c7;
    --table-header: #e0f2fe;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    padding: 16px 12px;
    max-width: 100%;
    transition: all 0.3s;
}

.container {
    max-width: 98%;
    margin: 0 auto;
    padding: 0 10px;
}

/* ===== HEADER ===== */
.header {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 1rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.logo p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.hidden {
    display: none !important;
}

/* ===== BUTTONS ===== */
.btn {
    border: none;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 40px;
    font-weight: 500;
    cursor: pointer;
    font-size: var(--font-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    color: var(--text-primary);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}
.btn-primary:hover {
    background: var(--primary-hover);
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-success {
    background: var(--success);
    color: white;
}
.btn-sm {
    padding: 4px 8px;
    font-size: 0.7rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sync-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}
.sync-indicator.online { background: var(--success); }
.sync-indicator.offline { background: var(--danger); }
.sync-indicator.syncing { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.pending-badge {
    background: var(--warning);
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: var(--font-base);
    font-weight: 600;
    border-radius: 40px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: 0.3s;
}
.tab-btn.active {
    background: var(--primary);
    color: white;
}
.tab-btn:hover:not(.active) {
    background: var(--table-header);
}

.tab-pane {
    display: none;
}
.tab-pane.active-pane {
    display: block;
}


.card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}


.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input, select, textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: var(--font-sm);
    color: var(--text-primary);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}


table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

th {
    background: var(--table-header);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}
th:hover {
    background: var(--primary);
    color: white;
}

.table-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.action-icons i {
    margin: 0 5px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.2s;
}
.action-icons i.fa-edit { color: var(--primary); }
.action-icons i.fa-trash { color: var(--danger); }
.action-icons i.fa-reply { color: var(--success); }
.action-icons i:hover { transform: scale(1.15); }


.badge {
    border-radius: 40px;
    padding: 2px 12px;
    font-size: 0.75rem;
    white-space: nowrap;
    display: inline-block;
}
.badge-primary { background: var(--primary); color: white; }
.badge-success { background: var(--success); color: white; }
.badge-danger { background: var(--danger); color: white; }
.badge-warning { background: var(--warning); color: #1f2937; }
.badge-info { background: #3b82f6; color: white; }

.priority-low { background: #d1fae5; color: #065f46; }
.priority-medium { background: #fef3c7; color: #92400e; }
.priority-high { background: #fee2e2; color: #991b1b; }
.priority-critical { background: #7f1d1d; color: #fca5a5; }

.status-open { background: #fef3c7; color: #92400e; }
.status-reviewing { background: #dbeafe; color: #1e40af; }
.status-answered { background: #d1fae5; color: #065f46; }
.status-closed { background: #e5e7eb; color: #4b5563; }


.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border);
}
.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}


.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal.hidden {
    display: none;
}

.modal-box {
    background: var(--bg-card);
    padding: 28px;
    border-radius: 28px;
    width: 95%;
    max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    position: absolute;
    top: 10px;
    left: 20px;
}

.modal-box .form-grid {
    grid-template-columns: 1fr 1fr;
}


.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 0.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-bar select,
.filter-bar input,
.filter-bar .btn {
    font-size: var(--font-sm);
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    min-height: 40px;
    flex: 0 0 auto;
    min-width: 120px;
    max-width: 200px;
}

.filter-bar .btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
    min-width: unset;
    padding: 6px 16px;
}
.filter-bar .btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== LOGIN ===== */
.login-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-box {
    background: var(--bg-card);
    padding: 40px 30px;
    border-radius: 24px;
    width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.login-box input {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-primary);
}

.last-user-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    margin: 3px;
}

/* ===== TOAST ===== */
.toast-notif {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s;
}
.toast-notif.error { background: var(--danger); }
.toast-notif.warning { background: var(--warning); color: #1f2937; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    z-index: 99999;
    font-size: 0.9rem;
}

/* ===== SETTINGS ===== */
.settings-dropdown {
    position: relative;
    display: inline-block;
}

.settings-dropdown .dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    background: var(--bg-card);
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px solid var(--border);
    z-index: 1000;
    padding: 8px 0;
    margin-top: 4px;
}
.settings-dropdown .dropdown-content.show {
    display: block;
}
.settings-dropdown .dropdown-content .btn {
    border: none;
    background: transparent;
    padding: 10px 20px;
    width: 100%;
    text-align: right;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-primary);
    justify-content: flex-start;
}
.settings-dropdown .dropdown-content .btn:hover {
    background: var(--table-header);
}

.theme-buttons {
    display: flex;
    gap: 6px;
    padding: 4px 8px;
}
.theme-buttons .btn {
    flex: 1;
    justify-content: center;
    min-width: 60px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .modal-box { max-width: 98%; padding: 20px; }
    .modal-box .form-grid { grid-template-columns: 1fr; }
    .header { padding: 0.8rem 1rem; flex-direction: column; align-items: stretch; }
    .header-right { justify-content: center; flex-wrap: wrap; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select, .filter-bar input, .filter-bar .btn { width: 100%; max-width: 100%; }
    .tabs .tab-btn { padding: 8px 12px; font-size: 0.85rem; flex: 1; text-align: center; }
    .login-box { width: 95%; padding: 24px 16px; }
}

@media (max-width: 480px) {
    .logo h1 { font-size: 1.2rem; }
    .logo p { font-size: 0.7rem; }
    .btn { padding: 6px 12px; font-size: 0.75rem; }
    .table-scroll { max-height: 350px; }
    th, td { padding: 6px 4px; font-size: 0.75rem; }
}

.table-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
}
.table-scroll::-webkit-scrollbar-track {
    background: var(--bg-body);
    border-radius: 8px;
}

#ticketsTableWrapper table td:nth-child(3) {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#ticketsTableWrapper table td:nth-child(4) {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}