/* ==========================================================================
   Hodoori Team Management - Main Stylesheet
   Identity: #ffab31, #1b1b1b, #fdfcfb, #ebf1f6, #ffffff, #e5e5e5 | Tajawal
   ========================================================================== */

:root {
  --color-primary: #ffab31;
  --color-primary-hover: #f59e1b;
  --color-primary-light: #fff8ee;
  --color-primary-border: #fed7aa;
  
  --color-dark: #1b1b1b;
  --color-cream: #fdfcfb;
  --color-ice: #ebf1f6;
  --color-surface: #ffffff;
  --color-border: #e5e5e5;
  --color-border-subtle: #f0f0f0;
  
  --text-primary: #1b1b1b;
  --text-secondary: #5a5a5a;
  --text-muted: #8e8e8e;
  
  /* Status Colors */
  --status-not-started-bg: #f3f4f6;
  --status-not-started-text: #4b5563;
  --status-not-started-border: #e5e7eb;
  
  --status-in-progress-bg: #eff6ff;
  --status-in-progress-text: #1d4ed8;
  --status-in-progress-border: #bfdbfe;
  
  --status-pending-bg: #fffbeb;
  --status-pending-text: #b45309;
  --status-pending-border: #fde68a;
  
  --status-revision-bg: #fef2f2;
  --status-revision-text: #b91c1c;
  --status-revision-border: #fecaca;
  
  --status-completed-bg: #ecfdf5;
  --status-completed-text: #047857;
  --status-completed-border: #a7f3d0;
  
  --priority-high-bg: #fee2e2;
  --priority-high-text: #dc2626;
  --priority-medium-bg: #fef3c7;
  --priority-medium-text: #d97706;
  --priority-low-bg: #e0f2fe;
  --priority-low-text: #0284c7;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

  --font-tajawal: 'Tajawal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-tajawal);
  background-color: var(--color-cream);
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ==========================================================================
   Utility Classes & Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-dark);
  border-color: #f59e1b;
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgba(255, 171, 49, 0.35);
}

.btn-dark {
  background-color: var(--color-dark);
  color: #ffffff;
}
.btn-dark:hover:not(:disabled) {
  background-color: #333333;
}

.btn-outline {
  background-color: var(--color-surface);
  color: var(--text-primary);
  border-color: var(--color-border);
}
.btn-outline:hover:not(:disabled) {
  background-color: var(--color-ice);
  border-color: #d1d5db;
}

.btn-success {
  background-color: #10b981;
  color: #ffffff;
}
.btn-success:hover:not(:disabled) {
  background-color: #059669;
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

.btn-warning {
  background-color: #f59e0b;
  color: #ffffff;
}
.btn-warning:hover:not(:disabled) {
  background-color: #d97706;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Card Container */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: #d8d8d8;
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-label .required {
  color: #ef4444;
  margin-right: 4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 171, 49, 0.2);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-help {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-not-started {
  background-color: var(--status-not-started-bg);
  color: var(--status-not-started-text);
  border-color: var(--status-not-started-border);
}

.badge-in-progress {
  background-color: var(--status-in-progress-bg);
  color: var(--status-in-progress-text);
  border-color: var(--status-in-progress-border);
}

.badge-pending {
  background-color: var(--status-pending-bg);
  color: var(--status-pending-text);
  border-color: var(--status-pending-border);
}

.badge-revision {
  background-color: var(--status-revision-bg);
  color: var(--status-revision-text);
  border-color: var(--status-revision-border);
}

.badge-completed {
  background-color: var(--status-completed-bg);
  color: var(--status-completed-text);
  border-color: var(--status-completed-border);
}

.badge-overdue {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
  animation: pulse-overdue 2s infinite ease-in-out;
}

@keyframes pulse-overdue {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.priority-badge {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.priority-high {
  background-color: var(--priority-high-bg);
  color: var(--priority-high-text);
}
.priority-medium {
  background-color: var(--priority-medium-bg);
  color: var(--priority-medium-text);
}
.priority-low {
  background-color: var(--priority-low-bg);
  color: var(--priority-low-text);
}

/* ==========================================================================
   Header & App Navigation
   ========================================================================== */
.app-header {
  height: 64px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-dark);
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-badge-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background-color: var(--color-ice);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
}

.user-badge-role {
  background-color: var(--color-dark);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.user-badge-role.admin {
  background-color: var(--color-primary);
  color: var(--color-dark);
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.app-sidebar {
  width: 250px;
  background-color: var(--color-surface);
  border-left: 1px solid var(--color-border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link:hover {
  background-color: var(--color-ice);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--color-primary-light);
  color: var(--color-dark);
  border-color: var(--color-primary-border);
}

.nav-link .material-symbols-outlined {
  font-size: 22px;
}

.nav-badge {
  margin-right: auto;
  background-color: var(--color-primary);
  color: var(--color-dark);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.app-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* Bottom Nav for Mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  z-index: 50;
  justify-content: space-around;
  align-items: center;
  padding: 0 12px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  position: relative;
}

.bottom-nav-item.active {
  color: var(--color-dark);
  font-weight: 700;
}

.bottom-nav-item.active .material-symbols-outlined {
  color: var(--color-primary);
}

/* ==========================================================================
   Stat Grid & Dashboard Counters
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background-color: var(--card-accent, var(--color-primary));
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-card-header .material-symbols-outlined {
  font-size: 24px;
  color: var(--card-accent, var(--color-primary));
}

.stat-card-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-dark);
  line-height: 1.1;
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Tables & Lists
   ========================================================================== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.95rem;
}

.custom-table th {
  background-color: #fafafa;
  color: var(--text-secondary);
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.custom-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.custom-table tr:hover td {
  background-color: #fafbfc;
}

/* Task Item Card */
.task-item-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.2s ease;
  cursor: pointer;
  margin-bottom: 12px;
}

.task-item-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.task-item-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.task-item-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-dark);
}

.task-item-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.task-item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(27, 27, 27, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-backdrop.open .modal-container {
  transform: scale(1);
}

.modal-container.lg {
  max-width: 860px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-dark);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 24px;
  display: flex;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.modal-close:hover {
  background-color: var(--color-ice);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: #fafbfc;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  background-color: var(--color-ice);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.upload-dropzone .material-symbols-outlined {
  font-size: 44px;
  color: var(--color-primary);
}

.file-list-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: #fafafa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.file-info .material-symbols-outlined {
  color: var(--color-primary);
  font-size: 22px;
}

.file-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.file-size {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Submissions Version History */
.submission-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  background-color: #ffffff;
  margin-bottom: 16px;
}

.submission-card.current {
  border-color: var(--color-primary);
  background-color: #fffdf9;
}

.submission-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.submission-version-badge {
  font-weight: 700;
  font-size: 0.9rem;
  background-color: var(--color-ice);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.review-box {
  background-color: #f8fafc;
  border-right: 4px solid var(--color-primary);
  padding: 12px 16px;
  border-radius: 4px;
  margin-top: 12px;
}

.review-box.revision {
  border-right-color: #ef4444;
  background-color: #fef2f2;
}

.review-box.approved {
  border-right-color: #10b981;
  background-color: #ecfdf5;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 300px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-success {
  background-color: #10b981;
}

.toast-error {
  background-color: #ef4444;
}

.toast-info {
  background-color: var(--color-dark);
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .material-symbols-outlined {
  font-size: 56px;
  color: #d1d5db;
  margin-bottom: 14px;
}

.empty-state-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-dark);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 auto 20px;
}

/* Responsive */
@media (max-width: 900px) {
  .app-sidebar {
    display: none;
  }
  
  .bottom-nav {
    display: flex;
  }
  
  .app-content {
    padding: 20px 16px 80px;
  }
  
  .app-header {
    padding: 0 16px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .task-item-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
