@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir.woff2') format('woff2'),
         url('../fonts/Vazir.woff') format('woff'),
         url('../fonts/Vazir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --table-header: #f8fafc;
}

[data-theme='dark'] {
    --bg: #0f172a;
    --card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --table-header: #0f172a;
    --btn-secondary-bg: #334155;
    --btn-secondary-text: #f8fafc;
    --info-bg: rgba(30, 41, 59, 0.5);
}

[data-theme='light'] {
    --table-header: #f8fafc;
    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-text: #0f172a;
    --info-bg: #ecfdf5;
}

/* --- THEME SYSTEM V3.5 --- */

/* 1. Modern Glass Theme */
[data-admin-theme='modern_glass'] {
    --bg: #f0f2f5;
    --card: rgba(255, 255, 255, 0.85);
    --sidebar-bg: rgba(255, 255, 255, 0.7);
    --border: rgba(255, 255, 255, 0.3);
    --primary: #4f46e5;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --radius: 20px;
}

[data-admin-theme='modern_glass'] body {
    background: radial-gradient(circle at top right, #e0e7ff 0%, #f1f5f9 50%, #fef2f2 100%);
    background-attachment: fixed;
}

[data-admin-theme='modern_glass'] .card, 
[data-admin-theme='modern_glass'] .sidebar,
[data-admin-theme='modern_glass'] .stat-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
}

[data-admin-theme='modern_glass'] .menu-item:hover {
    background: rgba(79, 70, 229, 0.08);
}

/* 2. Dark Pro Theme */
[data-admin-theme='dark_pro'] {
    --bg: #0b0e14;
    --card: #151921;
    --sidebar-bg: #151921;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #262c36;
    --primary: #3b82f6;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --table-header: #1c232d;
    --radius: 12px;
}

[data-admin-theme='dark_pro'] .stat-card {
    border-right: 4px solid var(--primary);
}

[data-admin-theme='dark_pro'] .menu-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-left: 3px solid var(--primary);
}

/* 3. Classic (Refined) */
[data-admin-theme='classic'] {
    --primary: #1e293b;
    --radius: 10px;
}

/* Layout Polishing for all themes */
.app-container {
    transition: all 0.4s ease;
}

.menu-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.menu-item::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: currentColor;
    opacity: 0;
    top: 0;
    left: 0;
    transition: opacity 0.3s;
}

.menu-item:active::after { opacity: 0.1; }

.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

.theme-glow {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 60px;
    height: 60px;
    background: var(--primary);
    filter: blur(40px);
    opacity: 0.15;
    z-index: -1;
}

/* Transitions */
body, .sidebar, .card, .stat-card, .btn, .menu-item {
    transition: background-color 0.3s, border-color 0.3s, color 0.3s, box-shadow 0.3s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Vazir', 'Vazirmatn', 'Tahoma', 'Segoe UI', 'Arial', sans-serif !important;
    background-color: var(--bg);
    color: var(--text-main);
    direction: rtl;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--card);
    border-left: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 2rem 1rem;
}

.main-content { flex: 1; padding: 2rem; overflow-x: hidden; }

/* Dashboard Cards */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 1.5rem; 
    margin-bottom: 2.5rem; 
}

.main-content-grid {
    display: flex;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-content-grid { flex-direction: column; }
}

.stat-card {
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 0.9375rem;
    gap: 0.5rem;
    text-decoration: none;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25); }

.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-secondary:hover { background: #cbd5e1; color: #0f172a; }
[data-theme='dark'] .btn-secondary:hover { background: #475569; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; transform: translateY(-1px); }

/* Login Page Stylings */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg) 0%, #e2e8f0 100%);
    padding: 20px;
}
[data-theme='dark'] .login-wrapper {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* Local Vazirmatn fallback - User should upload fonts to assets/fonts/ */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}

.login-card {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    background: var(--card);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Drag and Drop Styling */
.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--primary) !important;
    background: rgba(37, 99, 235, 0.05) !important;
}

.sortable-chosen {
    background: #f1f5f9 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
[data-theme='dark'] .sortable-chosen {
    background: #334155 !important;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 10px !important;
    font-size: 1.2rem;
    text-align: center;
    background: rgba(0,0,0,0.02);
    user-select: none;
    -webkit-user-select: none;
}
.drag-handle:active { cursor: grabbing; }

/* Ensure fonts are applied correctly to all buttons and inputs */
button, input, select, textarea, .badge, .menu-item, .action-btn {
    font-family: 'Vazir', 'Tahoma', 'Arial', sans-serif !important;
}

.menu-item {
    font-size: 0.95rem;
    font-weight: 500;
}

.sortable-steps tr, .sortable-steps td {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* Voice Recorder UI */
.recorder-container {
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    margin-top: 1rem;
}

.recording-pulse {
    width: 12px;
    height: 12px;
    background: var(--danger);
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.record-timer {
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: bold;
    margin: 10px 0;
}

/* Form Fields */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control, 
input[type="text"], 
input[type="tel"],
input[type="number"],
input[type="url"], 
input[type="password"], 
input[type="email"], 
select, 
textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    background: var(--card);
    color: var(--text-main);
    transition: all 0.2s;
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Cards & Tables */
.card {
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

th {
    padding: 1rem;
    background: var(--table-header);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    border: none;
}

.badge-primary { background: #eff6ff; color: #2563eb; }
.badge-primary:hover { background: #2563eb; color: white; }

.badge-success { background: #ecfdf5; color: #10b981; }
.badge-success:hover { background: #10b981; color: white; }

.badge-warning { background: #fffbeb; color: #f59e0b; }
.badge-warning:hover { background: #f59e0b; color: white; }

.badge-danger { background: #fef2f2; color: #ef4444; }
.badge-danger:hover { background: #ef4444; color: white; }

.action-btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.action-btn:active {
    transform: translateY(0);
}

.action-edit { background: #fef3c7; color: #92400e; }
.action-edit:hover { background: #f59e0b; color: white; }

.action-delete { background: #fee2e2; color: #991b1b; }
.action-delete:hover { background: #ef4444; color: white; }

.action-view { background: #e0f2fe; color: #075985; }
.action-view:hover { background: #0ea5e9; color: white; }

.action-msg { background: #dcfce7; color: #166534; }
.action-msg:hover { background: #22c55e; color: white; }

.action-primary { background: #eff6ff; color: #1e40af; }
.action-primary:hover { background: #2563eb; color: white; }

/* Custom Badge Enhancements */
.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* Modern Card Titles */
.card-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
}

/* Sidebar Menu */
.menu-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
}

.menu-item:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.menu-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

/* Response Utilities */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { padding: 1rem; }
}
