/* ─── TEFDO ERP — Component Styles ──────────────────── */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: var(--font-base);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  outline: none;
  line-height: 1;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #a78bfa);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--font-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

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

/* Premium Filter Group */
.filter-group {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-btn {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-secondary);
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.filter-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Premium Report Button */
.btn-report {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-report:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
  filter: brightness(1.1);
}

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

/* Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-error {
  font-size: var(--font-xs);
  color: var(--danger);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

/* Cards */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-primary);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: var(--font-lg);
  font-weight: 600;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card.has-icon {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--space-4);
  align-items: center;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  border-color: var(--border-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card .stat-icon {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 0;
}

.stat-card .stat-value {
  font-size: var(--font-3xl);
  font-weight: 800;
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-card.has-icon .stat-value {
  margin-bottom: 0;
  align-self: end;
}

.stat-card .stat-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card.has-icon .stat-label {
  align-self: start;
}

/* Tables */
.table-container {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.table-header h3 {
  font-size: var(--font-lg);
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 20px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 20px;
  font-size: var(--font-base);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.data-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-draft {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

.badge-active {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.badge-on_hold {
  background: rgba(251, 191, 36, 0.15);
  color: #f59e0b;
}

.badge-completed {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.badge-cancelled {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-admin {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.badge-tech {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}

.badge-sales {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Toast */
#toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInUp 0.3s ease forwards;
  min-width: 300px;
  max-width: 450px;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-warning {
  border-left: 3px solid var(--warning);
}

.toast-info {
  border-left: 3px solid var(--info);
}

.toast-message {
  font-size: var(--font-sm);
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 95%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideInUp 0.3s ease;
}

@media (max-width: 768px) {
  .modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-header {
    padding: var(--space-4);
  }

  .modal-body {
    padding: var(--space-4);
    flex: 1;
  }

  .modal-footer {
    padding: var(--space-4);
  }

  /* Increase readability for mobile forms */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 1rem !important;
    /* Minimum 16px for mobile legibility and to prevent zoom */
    padding: 12px !important;
  }

  .form-label {
    font-size: 0.95rem !important;
    margin-bottom: 6px;
    color: var(--text-primary);
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .stat-card.has-icon {
    padding: var(--space-4);
  }

  .stat-card .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .stat-card .stat-value {
    font-size: var(--font-2xl);
  }
}

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

.modal-header h2 {
  font-size: var(--font-xl);
  font-weight: 600;
}

.modal-body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.progress-bar-fill.over {
  background: linear-gradient(90deg, var(--danger), #f97316);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--font-md);
  margin-bottom: var(--space-4);
}

/* Timer Widget */
.timer-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.timer-widget.running {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.timer-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 800;
  min-width: 90px;
  text-align: center;
  letter-spacing: -0.02em;
}

.timer-display.running {
  color: var(--success);
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
  animation: timerPulse 2s infinite;
}

@keyframes timerPulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.8;
  }

  100% {
    opacity: 1;
  }
}

.timer-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.timer-btn-start {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.timer-btn-start:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.timer-btn-stop {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.timer-btn-stop:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.timer-project-name {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
}