/* ==========================================================================
   Components CSS - Buttons, Cards, Forms, Stepper, Modal, Badges
   ========================================================================== */

/* Layout Shell */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
  padding: 24px 16px;
  transition: var(--transition-normal);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.brand-logo-icon {
  width: 42px;
  height: 42px;
  background: var(--gold-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--gold-glow);
  color: #0A0B0E;
  font-size: 20px;
  font-weight: bold;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background-color: rgba(212, 175, 55, 0.08);
  color: var(--gold-light);
  transform: translateX(-3px);
}

.nav-item.active {
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold-primary);
  font-weight: 700;
  border: 1px solid var(--border-gold-subtle);
  box-shadow: inset 0 0 12px rgba(212, 175, 55, 0.1);
}

.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  background: var(--gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-weight: 700;
  font-size: 0.95rem;
}

.user-info-text {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-label {
  font-size: 0.75rem;
  color: var(--gold-light);
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.top-navbar {
  height: 70px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-navbar);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.navbar-time-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pulse-beacon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-primary);
  animation: pulseBeacon 2s infinite;
}

@keyframes pulseBeacon {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(212, 175, 55, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

.content-wrapper {
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Luxury Cards */
.card-luxury {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: var(--transition-normal);
}

.card-luxury::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  opacity: 0.4;
}

.card-luxury:hover {
  border-color: var(--border-gold-subtle);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), var(--gold-subtle-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--gold-btn-gradient);
  color: #FFFFFF;
  box-shadow: 0 4px 14px -2px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px -2px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-gold-subtle);
}

.btn-outline-gold {
  background: transparent;
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
}

.btn-outline-gold:hover {
  background: rgba(212, 175, 55, 0.1);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.2);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
  background: var(--bg-card-subtle);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-draft {
  background: rgba(148, 163, 184, 0.12);
  color: #94A3B8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-submitted {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-reviewed {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-correction {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* Stepper Component */
.stepper-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin-bottom: 36px;
}

.stepper-nav::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 30px;
  right: 30px;
  height: 2px;
  background: var(--border-subtle);
  z-index: 1;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  cursor: pointer;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.step-item.active .step-circle {
  background: var(--gold-gradient);
  color: #0A0B0E;
  border-color: var(--gold-primary);
  box-shadow: var(--gold-glow);
}

.step-item.completed .step-circle {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.step-label {
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.step-item.active .step-label {
  color: var(--gold-primary);
}

/* Toast Alerts */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 320px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-popup);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-info { border-color: var(--gold-primary); }

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 90%;
  max-width: 650px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-popup);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold-light);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Mobile Responsiveness */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
  }
  .app-sidebar.open {
    right: 0;
    box-shadow: -10px 0 30px rgba(0,0,0,0.8);
  }
  .mobile-nav-toggle {
    display: block;
  }
}

@media (max-width: 768px) {
  .content-wrapper {
    padding: 16px;
  }
  .top-navbar {
    padding: 0 16px;
  }
  .stepper-nav {
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .step-label {
    display: none;
  }
}

/* Refined application shell */
.app-sidebar { width: 272px; padding: 20px 14px; }
.brand-header { padding: 4px 10px 20px; }
.nav-item { padding: 11px 14px; transition: all var(--transition-fast); }
.nav-item:hover { background-color: rgba(212, 175, 55, .10); color: var(--gold-light); }
.nav-item.active { background: rgba(212, 175, 55, .15); box-shadow: inset 0 0 0 1px rgba(212, 175, 55, .25); color: var(--gold-light); font-weight: 600; }
.top-navbar { min-height: 70px; }
.content-wrapper { padding: 30px 36px; }
.card-luxury { box-shadow: var(--shadow-card); border: 1px solid var(--border-gold-subtle); }
.card-luxury::before { opacity: .35; }
.btn { min-height: 42px; padding: 10px 18px; }
.btn-primary { box-shadow: var(--gold-glow); background: var(--gold-btn-gradient); color: #000; font-weight: 700; border: none; }
.btn-primary:hover { box-shadow: 0 12px 28px -6px rgba(212, 175, 55, .65); transform: translateY(-1px); }
.form-input, .form-textarea, .form-select { min-height: 48px; padding: 12px 15px; border: 1px solid var(--border-subtle); background: var(--bg-card-subtle); color: var(--text-primary); }
.form-input:focus, .form-textarea:focus, .form-select:focus { box-shadow: 0 0 0 3px rgba(212, 175, 55, .25); border-color: var(--gold-primary); outline: none; }

.btn:focus-visible, .nav-item:focus-visible, .form-input:focus-visible,
.form-textarea:focus-visible, .form-select:focus-visible, .mobile-nav-toggle:focus-visible {
  outline: 3px solid rgba(212, 175, 55, .4);
  outline-offset: 3px;
}

/* Login */
.login-page { min-height: calc(100vh - 162px); display: grid; place-items: center; padding: 32px 0; }
.login-card { width: min(100%, 476px); padding: 42px; background: var(--bg-card); border: 1px solid var(--border-gold-subtle); border-radius: 28px; box-shadow: var(--shadow-popup); position: relative; overflow: hidden; backdrop-filter: blur(12px); }
.login-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--gold-gradient); }
.login-intro { text-align: center; margin-bottom: 28px; }
.login-logo { width: 68px; height: 68px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center; background: var(--gold-gradient); color: #000; box-shadow: var(--gold-glow); font-size: 32px; font-weight: 800; }
.login-eyebrow { margin-bottom: 4px; color: var(--gold-primary); font-size: .85rem; font-weight: 800; letter-spacing: .04em; }
.login-intro h1 { font-size: 1.75rem; line-height: 1.35; margin-bottom: 6px; }
.login-description { color: var(--info); font-size: 1rem; font-weight: 750; }
.login-supporting-text { color: var(--text-muted); font-size: .86rem; margin: 9px auto 0; max-width: 340px; line-height: 1.9; }
.login-password-group { margin-bottom: 24px; }
.login-submit { width: 100%; min-height: 52px; font-size: 1rem; justify-content: space-between; padding-inline: 20px; }
.login-error { display: none; padding: 12px 14px; background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: var(--radius-md); color: var(--danger); margin-bottom: 20px; font-size: .88rem; }
.login-error[style*="block"] { display: block; }
.login-help { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: .78rem; }
.sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
  .sidebar-backdrop.visible { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .34); z-index: 90; backdrop-filter: blur(2px); }
}

@media (max-width: 768px) {
  .top-navbar {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 58px;
    height: auto;
  }
  .top-navbar > div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
  }
  .top-navbar > div:last-child {
    display: flex !important;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  .navbar-time-badge {
    font-size: 0.76rem;
    padding: 4px 8px;
    gap: 6px;
    max-width: calc(100vw - 180px);
    overflow: hidden;
    flex-wrap: nowrap;
  }
  .navbar-school-name {
    display: none;
  }
  .navbar-jalali-date {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
  }
  #theme-toggle-btn {
    padding: 6px 10px !important;
    font-size: 0.8rem;
    min-height: 36px !important;
  }
  .theme-btn-text {
    display: none;
  }
  .content-wrapper { padding: 14px 10px; }
  .toast-container { right: 10px; left: 10px; bottom: 10px; }
  .toast { min-width: 0; width: 100%; }
  .login-page { min-height: calc(100vh - 120px); padding: 16px 8px; }
  .login-card { padding: 22px 16px; border-radius: 20px; width: 100%; }
  .login-intro h1 { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .navbar-jalali-date {
    max-width: 90px;
    font-size: 0.72rem;
  }
  #server-live-time {
    font-size: 0.72rem;
  }
  .content-wrapper { padding: 10px 8px; }
  .card-luxury { padding: 16px 12px; }
  .btn { min-height: 38px; padding: 8px 14px; font-size: 0.88rem; }
}

