/* =============================================
   TaskFlow Pro - Premium Styles
   ============================================= */

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.1);
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ========== LOADING SCREEN ========== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s, visibility 0.5s;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loading-content { text-align: center; color: #fff; }

.loading-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.loading-title span {
  font-weight: 300;
  opacity: 0.8;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  margin: 1.5rem auto 0;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ========== AUTH SECTION ========== */
.auth-section { position: relative; min-height: 100vh; }

.auth-bg {
  position: fixed;
  inset: 0;
  background: var(--gradient);
  z-index: -1;
}

.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.06) 0%, transparent 50%);
}

.auth-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header { margin-bottom: 2rem; }

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--gradient);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #fff;
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.auth-header h2 {
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.5px;
}

.auth-header h2 span {
  font-weight: 300;
  color: var(--primary);
}

/* Auth Tabs */
.auth-tabs {
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
}

.auth-tabs .nav-link {
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 10px;
  transition: all 0.3s;
}

.auth-tabs .nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* Auth Forms */
.auth-card .form-control {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.auth-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.auth-card .form-floating > label {
  color: var(--text-muted);
}

#authAlert {
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
}

/* ========== DEMO BUTTON ========== */
.btn-demo {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px 24px;
  transition: all 0.3s;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.3);
}

.btn-demo:hover {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.4);
}

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

.btn-demo .btn-loader { display: inline-flex; align-items: center; color: #fff; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ========== BUTTONS ========== */
.btn-primary {
  background: var(--primary);
  border: none;
  border-radius: 10px;
  font-weight: 600;
  padding: 12px 24px;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

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

.btn-light {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
  color: var(--text);
}

.btn-light:hover { background: var(--border); }

.btn-danger {
  border-radius: 10px;
  font-weight: 600;
}

.btn-loader { display: inline-flex; align-items: center; }

/* ========== NAVBAR ========== */
.navbar-app {
  background: var(--gradient);
  padding: 1rem 0;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.navbar-app .navbar-brand {
  color: #fff;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
}

.navbar-app .navbar-brand span {
  font-weight: 300;
  opacity: 0.85;
}

.navbar-app .navbar-brand:hover { color: #fff; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.navbar-app .btn-outline-light {
  border-radius: 8px;
  font-weight: 500;
  border-width: 2px;
  font-size: 0.85rem;
}

/* ========== MAIN CONTENT ========== */
.main-content { padding: 2rem 0; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.page-subtitle { font-size: 0.9rem; margin: 0; }

.btn-add {
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.95rem;
}

/* ========== STATS CARDS ========== */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: transform 0.3s, box-shadow 0.3s;
}

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

.stat-total  { border-left-color: var(--primary); }
.stat-completed { border-left-color: var(--success); }
.stat-pending { border-left-color: var(--warning); }
.stat-overdue { border-left-color: var(--danger); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-total .stat-icon  { background: var(--primary-light); color: var(--primary); }
.stat-completed .stat-icon { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.stat-pending .stat-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-overdue .stat-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stat-info { display: flex; flex-direction: column; }

.stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========== TOOLBAR ========== */
.toolbar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.toolbar-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.toolbar-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.toolbar-search .form-control {
  padding-left: 42px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}

.toolbar-search .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.toolbar-filters {
  display: flex;
  gap: 0.75rem;
}

.toolbar-filters .form-select {
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 140px;
  cursor: pointer;
}

.toolbar-filters .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* ========== TODO TABLE ========== */
.todo-table-wrapper {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.todo-table {
  margin: 0;
  font-size: 0.9rem;
}

.todo-table thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 14px 16px;
}

.todo-table tbody tr {
  transition: background 0.2s;
}

.todo-table tbody tr:hover { background: #f8fafc; }

.todo-table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

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

/* Checkbox */
.todo-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  accent-color: var(--primary);
}

.todo-check:checked { border-color: var(--primary); }

/* Task cell */
.todo-title {
  font-weight: 600;
  color: var(--text);
  transition: color 0.3s;
}

.todo-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.todo-row-completed .todo-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-row-completed .todo-desc { opacity: 0.5; }

/* Priority Badge */
.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.priority-high {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.priority-medium {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.priority-low {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

/* Date cells */
.todo-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.todo-date-overdue { color: var(--danger); font-weight: 600; }

/* Action buttons */
.action-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.action-btn:hover { background: var(--bg); }
.action-btn-view:hover { color: var(--primary); }
.action-btn-edit:hover { color: var(--warning); }
.action-btn-delete:hover { color: var(--danger); background: rgba(239, 68, 68, 0.08); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 4rem;
  color: var(--border);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

/* ========== TABLE LOADING ========== */
.table-loading {
  text-align: center;
  padding: 3rem 2rem;
}

/* ========== MODALS ========== */
.custom-modal {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.custom-modal .modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.custom-modal .modal-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.custom-modal .modal-body { padding: 1.5rem; }

.custom-modal .modal-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.custom-modal .form-control,
.custom-modal .form-select {
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.custom-modal .form-control:focus,
.custom-modal .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* Delete Modal */
.delete-icon {
  width: 64px;
  height: 64px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--danger);
  margin-bottom: 1rem;
}

/* View Modal */
.view-field { margin-bottom: 1.25rem; }

.view-field-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.view-field-value {
  font-size: 0.95rem;
  color: var(--text);
}

/* ========== TOAST ========== */
.toast {
  border-radius: 10px;
  font-weight: 500;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .auth-card { padding: 1.75rem; }
  .page-title { font-size: 1.4rem; }
  .stat-card { padding: 1rem; }
  .stat-number { font-size: 1.2rem; }
  .toolbar { flex-direction: column; }
  .toolbar-search { width: 100%; }
  .toolbar-filters { width: 100%; }
  .toolbar-filters .form-select { flex: 1; min-width: 0; }

  .todo-table-wrapper { overflow-x: auto; }
  .todo-table { min-width: 700px; }
}

@media (max-width: 576px) {
  .main-content { padding: 1rem 0; }
  .container-fluid { padding-left: 12px; padding-right: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .btn-add { width: 100%; }
}
