:root {
  /* متغیرهای حالت روز (پیش‌فرض) */
  --bg-body: #f0f2f5;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --bg-glass-hover: rgba(255, 255, 255, 1);
  --border-color: rgba(200, 200, 200, 0.4);
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.3);
  --input-bg: #f9fafb;
  --input-border: #e5e7eb;
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
  
  --success: #10b981;
  --error: #ef4444;
  --radius: 16px;
  --font-family: "Vazirmatn", sans-serif;
}

[data-theme="dark"] {
  /* متغیرهای حالت شب */
  --bg-body: #0f172a;
  --bg-glass: rgba(30, 41, 59, 0.85);
  --bg-glass-hover: rgba(30, 41, 59, 0.95);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #818cf8;
  --primary-glow: rgba(129, 140, 248, 0.4);
  --input-bg: #1e293b;
  --input-border: #334155;
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  background-image: radial-gradient(circle at 10% 20%, var(--primary-glow) 0%, transparent 20%),
                    radial-gradient(circle at 90% 80%, var(--primary-glow) 0%, transparent 20%);
  overflow-x: hidden;
}

/* --- Theme Toggle Button --- */
.theme-btn {
  position: fixed;
  top: 20px;
  right: 20px; /* سمت راست صفحه */
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--bg-glass);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-main);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
}

.theme-btn .sun-icon { display: none; }
.theme-btn .moon-icon { display: block; }

[data-theme="dark"] .theme-btn .sun-icon { display: block; color: #facc15; }
[data-theme="dark"] .theme-btn .moon-icon { display: none; }

/* --- Layout --- */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hidden { display: none !important; }

/* --- Glass Cards --- */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

/* --- Login --- */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80vh;
}

.login-box {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-header { margin-bottom: 30px; }
.logo-icon {
  font-size: 3rem; color: var(--primary); margin-bottom: 15px;
  filter: drop-shadow(0 0 10px var(--primary-glow));
}
.login-header h2 { font-weight: 800; font-size: 1.8rem; margin-bottom: 5px; }

/* --- Dashboard Header --- */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  padding: 15px 30px;
}

.header-center h1 {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(to right, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: none; /* در موبایل مخفی */
}
@media(min-width: 768px) { .header-center h1 { display: block; } }

.header-right { display: flex; align-items: center; gap: 15px; }
.avatar-box img {
  width: 55px; height: 55px; border-radius: 18px;
  object-fit: cover; border: 2px solid var(--primary);
}
.user-meta h2 { font-size: 1rem; margin-bottom: 2px; }
.badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 6px; }
.badge-info { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }

.status-pill {
  background: var(--primary-glow); color: var(--primary);
  padding: 8px 16px; border-radius: 50px; font-weight: 700;
  display: flex; gap: 8px; align-items: center;
}

/* --- Form Styles --- */
.form-section { margin-bottom: 25px; }

.card-title {
  display: flex; align-items: center; gap: 10px; margin-bottom: 25px;
  color: var(--primary); font-size: 1.2rem; border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
}

.form-row {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

/* Grid System for Form */
.col-4 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .col-4 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .col-4 { grid-template-columns: repeat(4, 1fr); } }

.col-2 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .col-2 { grid-template-columns: 1fr 1fr; } }

.input-wrapper { display: flex; flex-direction: column; gap: 8px; }
.input-wrapper label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

input, select, textarea {
  width: 100%;
  padding: 12px 15px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  border-radius: 12px;
  font-size: 0.95rem;
  transition: 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  transform: translateY(-1px);
}
/* حالت نامعتبر (برای موبایل) */
input:invalid { border-color: var(--error); }

.text-center { text-align: center; }

/* Buttons */
.btn {
  cursor: pointer; border: none; border-radius: 12px;
  padding: 12px 24px; font-weight: 600; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-2px); }

.btn-outline {
  background: transparent; border: 2px dashed var(--border-color); color: var(--text-muted);
}
.btn-outline:hover {
  border-color: var(--primary); color: var(--primary); background: var(--input-bg);
}

.btn-block { width: 100%; }
.btn-wide { min-width: 200px; }
.btn-icon {
  background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem;
}
.btn-icon:hover { color: var(--primary); transform: rotate(180deg); transition: 0.4s; }

.glow-effect { box-shadow: 0 4px 15px var(--primary-glow); }

/* File Input */
.file-input-hidden { display: none; }
.form-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px;
  margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border-color);
}
.file-box { display: flex; align-items: center; gap: 15px; }
.file-msg { font-size: 0.85rem; color: var(--text-muted); }

/* Logs Section */
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.logs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}

.log-item {
  background: var(--input-bg);
  padding: 15px;
  border-radius: 12px;
  border-right: 4px solid var(--primary);
  display: flex; flex-direction: column; gap: 5px;
}
.log-item h4 { font-size: 0.95rem; color: var(--text-main); }
.log-item .muted { font-size: 0.8rem; color: var(--text-muted); }

/* Status Messages */
.status-msg { margin-top: 15px; font-size: 0.9rem; min-height: 20px; }
.status-msg.error { color: var(--error); }
.status-msg.success { color: var(--success); }
.inline { margin: 0; }

/* Responsive Adjustments */
@media (max-width: 768px) {
  .form-footer { flex-direction: column; align-items: stretch; }
  .btn-wide { width: 100%; }
  .theme-btn { top: 10px; right: 10px; width: 40px; height: 40px; }
}

button.btn.btn-primary.btn-block.glow-effect {
    margin-top: 10px;
}