/* ==========================================
   سیستم جامع مدیریت تولید پوشاک - نسخه ۳.۰
   ========================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
}

:root {
  --primary: #3498db;
  --primary-dark: #2980b9;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --purple: #9b59b6;
  --dark: #2c3e50;
  --gray: #7f8c8d;
  --light-gray: #ecf0f1;
  --bg: #f0f2f5;
  --white: #ffffff;
}

body {
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  direction: rtl;
  padding-bottom: 40px;
}

.page {
  display: none;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.page.active {
  display: block;
}

.hidden {
  display: none !important;
}

/* ==========================================
   صفحه لاگین
   ========================================== */

#loginPage {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#loginPage.active {
  display: flex;
}

.login-box {
  max-width: 420px;
  width: 100%;
  background: var(--white);
  padding: 40px 32px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.login-logo {
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-box h1 {
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--dark);
  font-weight: 700;
}

.subtitle {
  color: var(--gray);
  margin-bottom: 28px;
  font-size: 13px;
}

.hint {
  color: #95a5a6;
  font-size: 12px;
  margin-top: 16px;
}

.hint i {
  margin-left: 4px;
}

/* ==========================================
   فرم
   ========================================== */

.form-group {
  margin-bottom: 16px;
  text-align: right;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
}

.form-group label i {
  color: var(--primary);
  margin-left: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  transition: all 0.2s;
  color: var(--dark);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(52,152,219,0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ==========================================
   فیلدهای زمان AM/PM
   ========================================== */

.time-input {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.time-input select {
  padding: 10px 4px;
  border: 2px solid #e8e8e8;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  text-align: center;
  transition: all 0.2s;
}

.time-input select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
}

.time-hour { width: 62px; }
.time-minute { width: 62px; }
.time-ampm { width: 78px; }

.time-input span {
  font-weight: 700;
  color: var(--gray);
  font-size: 16px;
}

.time-text-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px dashed #dcdde1;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  background: #fafafa;
  text-align: center;
  direction: ltr;
  color: var(--gray);
  transition: all 0.2s;
}

.time-text-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
  border-style: solid;
  color: var(--dark);
}

/* ==========================================
   دکمه‌ها
   ========================================== */

button {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
  font-weight: 500;
}

button i {
  margin-left: 4px;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

button:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  width: 100%;
}

.btn-success {
  background: linear-gradient(135deg, #27ae60, #229954);
  color: var(--white);
  width: 100%;
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: var(--white);
  width: 100%;
}

.btn-warning {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: var(--white);
  width: 100%;
}

.btn-logout {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  padding: 8px 14px;
  font-size: 14px;
  margin: 0;
  border: 1px solid rgba(255,255,255,0.3);
}

.btn-logout:hover {
  background: rgba(255,255,255,0.3);
}

.btn-small {
  padding: 5px 12px;
  font-size: 12px;
  margin: 0 3px;
}

.btn-edit {
  background: #f39c12;
  color: var(--white);
}

.btn-delete {
  background: #e74c3c;
  color: var(--white);
}

.btn-info {
  background: #3498db;
  color: var(--white);
}

/* ==========================================
   هدر
   ========================================== */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  padding: 14px 18px;
  border-radius: 14px;
  margin-bottom: 16px;
  box-shadow: 0 6px 20px rgba(52,152,219,0.3);
  gap: 12px;
  color: var(--white);
}

.app-header h2 {
  font-size: 16px;
  color: var(--white);
}

.header-info {
  flex: 1;
  text-align: center;
}

.header-info h2 i {
  margin-left: 6px;
}

.hamburger-btn {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  padding: 8px 14px;
  font-size: 18px;
  margin: 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3);
}

.hamburger-btn:hover {
  background: rgba(255,255,255,0.3);
}

.user-badge {
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  display: block;
  margin-top: 4px;
}

/* ==========================================
   منوی همبرگری
   ========================================== */

.hamburger-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--white);
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: right 0.3s ease;
  overflow-y: auto;
}

.hamburger-menu.open {
  right: 0;
}

.hamburger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: var(--white);
}

.hamburger-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.hamburger-brand i {
  font-size: 20px;
}

.hamburger-header button {
  background: transparent;
  color: var(--white);
  font-size: 18px;
  margin: 0;
  padding: 4px 8px;
}

.hamburger-user {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #ecf0f1;
  font-size: 13px;
  color: var(--gray);
}

.hamburger-user strong {
  color: var(--dark);
  display: block;
  margin-bottom: 4px;
}

#menuItems {
  padding: 8px;
}

#menuItems a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--dark);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 2px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

#menuItems a i {
  width: 20px;
  text-align: center;
  color: var(--primary);
  font-size: 15px;
}

#menuItems a:hover {
  background: var(--light-gray);
  transform: translateX(-2px);
}

#menuItems a.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
}

#menuItems a.active i {
  color: var(--white);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  display: none;
  backdrop-filter: blur(2px);
}

.menu-overlay.open {
  display: block;
}

/* ==========================================
   بنر نوتیفیکیشن
   ========================================== */

.notification-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: var(--white);
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(243,156,18,0.4);
  max-width: 500px;
  width: calc(100% - 40px);
  animation: slideDown 0.4s ease;
}

@keyframes slideDown {
  from { transform: translate(-50%, -100px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.notif-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notif-icon {
  font-size: 24px;
  animation: shake 1s infinite;
}

@keyframes shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(15deg); }
  75% { transform: rotate(-15deg); }
}

.notif-text {
  flex: 1;
}

.notif-text strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.notif-text span {
  font-size: 12px;
  opacity: 0.95;
}

.notif-close {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  padding: 4px 8px;
  margin: 0;
  border-radius: 6px;
}

/* ==========================================
   بنر هشدار مدیر
   ========================================== */

.admin-alert-banner {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: var(--white);
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(231,76,60,0.3);
  font-size: 14px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(231,76,60,0.3); }
  50% { box-shadow: 0 4px 24px rgba(231,76,60,0.6); }
}

.admin-alert-banner i {
  font-size: 20px;
}

.admin-alert-banner span {
  flex: 1;
}

.admin-alert-banner button {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  padding: 4px 10px;
  margin: 0;
}

/* ==========================================
   کارت
   ========================================== */

.card {
  background: var(--white);
  padding: 20px;
  border-radius: 14px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
}

.card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--light-gray);
}

.card h3 i {
  color: var(--primary);
  font-size: 18px;
}

.sub-title {
  font-size: 14px;
  margin: 20px 0 12px;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-title i {
  color: var(--purple);
}

/* ==========================================
   کارت تحلیل
   ========================================== */

.analysis-card {
  border-right: 5px solid var(--primary);
  background: linear-gradient(135deg, var(--white) 0%, #f8fbff 100%);
}

.analysis-item {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.7;
  transition: transform 0.2s;
}

.analysis-item:hover {
  transform: translateX(-3px);
}

.analysis-item:last-child { margin-bottom: 0; }

.analysis-good {
  background: linear-gradient(135deg, #d4efdf, #eafaf1);
  color: #1e8449;
  border-right: 4px solid var(--success);
}

.analysis-warn {
  background: linear-gradient(135deg, #fef5e7, #fef9f3);
  color: #b9770e;
  border-right: 4px solid var(--warning);
}

.analysis-bad {
  background: linear-gradient(135deg, #fadbd8, #fdedec);
  color: #922b21;
  border-right: 4px solid var(--danger);
}

.analysis-info {
  background: linear-gradient(135deg, #ebf5fb, #f4f9fc);
  color: #21618c;
  border-right: 4px solid var(--primary);
}

.analysis-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.analysis-item .suggestion {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.9;
}

/* ==========================================
   آمار
   ========================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--white);
  padding: 18px 14px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: all 0.3s;
  border: 1px solid rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--purple));
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.stat-icon {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 8px;
  display: block;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--dark);
}

/* ==========================================
   وضعیت
   ========================================== */

.status-badge {
  display: inline-block;
  margin-right: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--light-gray);
  font-weight: 500;
}

.status-badge.open {
  background: #d4efdf;
  color: var(--success);
}

.status-badge.closed {
  background: #fadbd8;
  color: var(--danger);
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

.warning-banner {
  background: linear-gradient(135deg, #fff3cd, #fffbea);
  color: #856404;
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  border-right: 4px solid var(--warning);
  display: flex;
  align-items: center;
  gap: 10px;
}

.warning-banner i {
  font-size: 18px;
  color: var(--warning);
}

/* ==========================================
   لاگ و لیست
   ========================================== */

.log-item {
  padding: 12px;
  border-bottom: 1px solid var(--light-gray);
  font-size: 13px;
  line-height: 1.7;
}

.log-item:last-child { border-bottom: none; }

.log-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--light-gray);
  font-size: 14px;
  gap: 12px;
  flex-wrap: wrap;
  transition: background 0.2s;
}

.list-row:hover {
  background: #fafbfc;
}

.list-row:last-child { border-bottom: none; }

.list-row-info {
  flex: 1;
  min-width: 200px;
}

.list-row-info strong {
  display: block;
  margin-bottom: 4px;
  color: var(--dark);
}

.list-row-info small {
  color: var(--gray);
  font-size: 12px;
}

.list-row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ==========================================
   جدول
   ========================================== */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--light-gray);
}

.data-table th {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-weight: 600;
  color: var(--white);
  font-size: 12px;
}

.data-table tr:hover {
  background: #f8f9fa;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.rank-1 { color: #f39c12; font-weight: 700; font-size: 16px; }
.rank-2 { color: #95a5a6; font-weight: 700; font-size: 16px; }
.rank-3 { color: #cd7f32; font-weight: 700; font-size: 16px; }

.badge-reward {
  background: #d4efdf;
  color: var(--success);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-penalty {
  background: #fadbd8;
  color: var(--danger);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-neutral {
  background: var(--light-gray);
  color: var(--gray);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================
   جدول فرایند و سفارش
   ========================================== */

.process-table,
.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fafbfc;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.process-table th,
.process-table td,
.order-table th,
.order-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid #ecf0f1;
}

.process-table th,
.order-table th {
  background: #e8f4f8;
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
}

.process-table input,
.process-table select,
.order-table input,
.order-table select {
  width: 100%;
  padding: 6px 4px;
  border: 1px solid #dcdde1;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  text-align: center;
  background: var(--white);
}

.process-table input:focus,
.order-table input:focus {
  outline: none;
  border-color: var(--primary);
}

.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ddd;
  vertical-align: middle;
}

/* ==========================================
   کارت ماشین
   ========================================== */

.machine-card {
  background: var(--white);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-right: 5px solid var(--primary);
}

.machine-card.excellent { border-right-color: var(--success); }
.machine-card.good { border-right-color: #2ecc71; }
.machine-card.medium { border-right-color: var(--warning); }
.machine-card.bad { border-right-color: var(--danger); }

.machine-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--light-gray);
}

.machine-card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.machine-card-score {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}

.machine-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.machine-stat {
  text-align: center;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 8px;
}

.machine-stat-label {
  display: block;
  font-size: 11px;
  color: var(--gray);
  margin-bottom: 4px;
}

.machine-stat-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.machine-card-suggestion {
  background: #f8f9fa;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--dark);
}

/* ==========================================
   سکشن‌های مدیر
   ========================================== */

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

/* ==========================================
   مودال
   ========================================== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--white);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: var(--white);
  border-radius: 16px 16px 0 0;
}

.modal-header h3 {
  font-size: 16px;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--white);
}

.modal-header button {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  padding: 6px 10px;
  margin: 0;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  background: #f8f9fa;
  border-radius: 0 0 16px 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-footer button {
  margin: 0;
  width: auto;
}

/* ==========================================
   موبایل
   ========================================== */

@media (max-width: 700px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .app-header h2 {
    font-size: 14px;
  }

  .app-header {
    padding: 10px 14px;
  }

  .hamburger-menu {
    width: 260px;
  }

  .data-table {
    font-size: 11px;
  }

  .data-table th,
  .data-table td {
    padding: 6px 4px;
  }

  .time-hour,
  .time-minute {
    width: 52px;
    font-size: 13px;
  }

  .time-ampm {
    width: 68px;
    font-size: 13px;
  }

  .stat-value {
    font-size: 20px;
  }

  .machine-card-stats {
    grid-template-columns: 1fr 1fr;
  }

  .login-box {
    padding: 30px 20px;
  }

  .notification-banner {
    top: 10px;
    width: calc(100% - 20px);
  }
}

@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .time-hour,
  .time-minute {
    width: 46px;
    font-size: 12px;
  }

  .time-ampm {
    width: 62px;
    font-size: 12px;
  }
}