@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
  --primary: #1b3b6f;
  --primary-hover: #16305b;
  --accent-red: #dc2626;
  --accent-red-hover: #b91c1c;
  --bg-slate: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 10px 25px -5px rgba(27, 59, 111, 0.15);
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-sans: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-slate);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 520px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.header {
  background: linear-gradient(135deg, var(--primary) 0%, #2e5b9b 100%);
  color: white;
  padding: 24px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
  border-bottom: 4px solid var(--accent-red);
}

/* Subtle background graphic for header */
.header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.header-logo {
  width: 68px;
  height: 68px;
  background: #ffffff;
  border-radius: 50%;
  padding: 3px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.25);
  animation: pulse 3s infinite ease-in-out;
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 2;
}

.header h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.1;
  text-transform: uppercase;
}

.header p {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
  letter-spacing: 0.5px;
  color: #e2e8f0;
}

.header .tagline {
  font-size: 11px;
  font-style: italic;
  font-weight: 400;
  opacity: 0.75;
  color: #cbd5e1;
  margin-top: 2px;
}

.card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-label-container {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.card-label-container svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  width: 100%;
}

select,
textarea,
input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: #ffffff;
  transition: all 0.2s ease;
  appearance: none; /* remove default appearance for select */
}

/* Custom select styling */
select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

textarea {
  min-height: 100px;
  resize: none;
  line-height: 1.5;
}

select:focus,
textarea:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(27, 59, 111, 0.12);
  background-color: #ffffff;
}

select:hover:not(:focus),
textarea:hover:not(:focus),
input:hover:not(:focus) {
  border-color: #cbd5e1;
}

button {
  width: 100%;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  color: white;
  padding: 16px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(27, 59, 111, 0.3);
  background: linear-gradient(135deg, var(--primary-hover) 0%, #172554 100%);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

#status {
  text-align: center;
  font-weight: 600;
  transition: all 0.3s ease;
}

#status:not(:empty) {
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Fallback/Neutral layout when not modified by MutationObserver */
#status:not(:empty) {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Dynamic styling for status classes added by JS */
.status-success {
  background: #f0fdf4 !important;
  color: #166534 !important;
  border-color: #bbf7d0 !important;
  box-shadow: 0 4px 6px -1px rgba(22, 101, 52, 0.05) !important;
}

.status-error {
  background: #fef2f2 !important;
  color: #991b1b !important;
  border-color: #fecaca !important;
  box-shadow: 0 4px 6px -1px rgba(153, 27, 27, 0.05) !important;
}

.status-loading {
  background: #f0f9ff !important;
  color: #075985 !important;
  border-color: #bae6fd !important;
  box-shadow: 0 4px 6px -1px rgba(7, 89, 133, 0.05) !important;
}

/* Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 6px 15px rgba(27, 59, 111, 0.25);
  }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  body {
    padding: 16px 12px;
  }
  
  .header {
    padding: 20px;
    gap: 16px;
  }
  
  .header-logo {
    width: 56px;
    height: 56px;
  }
  
  .header h1 {
    font-size: 22px;
  }
  
  .header p {
    font-size: 12px;
  }
  
  .card {
    padding: 16px;
  }
}

/* =====================================================
   CONTAINER WIDE STATE
   ===================================================== */
#mainContainer {
  transition: max-width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
#mainContainer.wide {
  max-width: 960px;
}

/* =====================================================
   TAB NAVIGATION STYLING
   ===================================================== */
.tab-navigation {
  display: flex;
  background: rgba(226, 232, 240, 0.6);
  padding: 6px;
  border-radius: 14px;
  gap: 6px;
  margin-bottom: 8px;
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  box-shadow: none;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tab-btn svg {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  transform: none;
  box-shadow: none;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.05);
}

.tab-btn.active svg {
  color: var(--primary);
  transform: scale(1.05);
}

/* Tab Content toggling */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  animation: tabFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
  display: flex;
}

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

/* =====================================================
   DASHBOARD STATS GRID
   ===================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: 100%;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

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

.stat-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

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

.stat-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

/* Stat card themes */
.stat-card.total .stat-icon-wrapper {
  background: #eff6ff;
  color: #2563eb;
}
.stat-card.completed .stat-icon-wrapper {
  background: #f0fdf4;
  color: #16a34a;
}
.stat-card.started .stat-icon-wrapper {
  background: #eef2ff;
  color: #4f46e5;
}
.stat-card.pending .stat-icon-wrapper {
  background: #fff7ed;
  color: #ea580c;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card {
    padding: 12px;
  }
  .stat-val {
    font-size: 18px;
  }
}

/* =====================================================
   CONTROLS & FILTERING
   ===================================================== */
.controls-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  padding-left: 44px;
  font-size: 14px;
}

.filter-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-controls select {
  width: 160px;
  font-size: 14px;
  padding: 10px 36px 10px 14px;
}

.icon-btn {
  width: 44px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  padding: 0;
}

.icon-btn:hover {
  background: var(--bg-slate);
  border-color: #cbd5e1;
  color: var(--primary);
  transform: translateY(-1px);
}

.icon-btn svg {
  transition: transform 0.4s ease;
}

.icon-btn:active svg {
  transform: scale(0.9);
}

.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  .controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-controls {
    justify-content: space-between;
  }
  .filter-controls select {
    flex: 1;
    width: auto;
  }
}

/* =====================================================
   TASKS LIST GRID & CARDS
   ===================================================== */
.tasks-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  min-height: 200px;
}

@media (max-width: 768px) {
  .tasks-container {
    grid-template-columns: 1fr;
  }
}

.task-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

/* Priority Indicator Border */
.task-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #cbd5e1; /* default */
}
.task-card.priority-urgent::before { background: var(--accent-red); }
.task-card.priority-high::before { background: #f97316; }
.task-card.priority-medium::before { background: #eab308; }
.task-card.priority-low::before { background: #3b82f6; }

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.task-worker-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-worker-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
}

.task-worker-id {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.task-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Status Badges */
.badge.status-completed {
  background: #dcfce7;
  color: #15803d;
}
.badge.status-started {
  background: #e0e7ff;
  color: #4338ca;
}
.badge.status-pending {
  background: #ffedd5;
  color: #c2410c;
}
.badge.status-unknown {
  background: #f1f5f9;
  color: #475569;
}

/* Priority Badges */
.badge.priority-urgent { background: #fee2e2; color: #b91c1c; }
.badge.priority-high { background: #ffedd5; color: #ea580c; }
.badge.priority-medium { background: #fef9c3; color: #a16207; }
.badge.priority-low { background: #eff6ff; color: #1d4ed8; }

.task-card-body {
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
  white-space: pre-line;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  flex-grow: 1;
}

.task-card-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  color: var(--text-muted);
}

.date-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.date-label {
  font-weight: 600;
  font-size: 9px;
  text-transform: uppercase;
  color: #94a3b8;
}

.date-val {
  font-weight: 500;
  color: #475569;
}

/* Overdue logic color indicator */
.date-item.overdue .date-val {
  color: var(--accent-red);
  font-weight: 600;
}

/* =====================================================
   DRIVE PROOF IMAGE PREVIEWS
   ===================================================== */
.task-card-proof {
  margin-top: 4px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.proof-title-container {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.proof-title-container svg {
  color: var(--primary);
}

.proof-image-wrapper {
  position: relative;
  width: 100%;
  height: 130px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  cursor: pointer;
  transition: all 0.25s ease;
}

.proof-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.proof-image-wrapper:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(27, 59, 111, 0.12);
}

.proof-image-wrapper:hover img {
  transform: scale(1.05);
}

.image-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s ease;
  gap: 6px;
}

.proof-image-wrapper:hover .image-overlay {
  opacity: 1;
}

/* Fallback card for when drive thumbnail fails (e.g. auth issue) */
.drive-fallback-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px dashed var(--border-color);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
}

.drive-fallback-card svg {
  color: #22c55e; /* Drive green */
  animation: pulse 2.5s infinite ease-in-out;
}

.drive-fallback-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.drive-fallback-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.drive-fallback-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* =====================================================
   STATES (LOADING, EMPTY, ERROR)
   ===================================================== */
.loading-state,
.empty-state,
.error-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.loading-state p,
.empty-state p,
.error-state p {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3.5px solid rgba(27, 59, 111, 0.15);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.empty-state svg,
.error-state svg {
  color: #94a3b8;
}

.error-state svg {
  color: var(--accent-red);
}

.error-state .retry-btn {
  background: var(--accent-red);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 120px;
}

.error-state .retry-btn:hover {
  background: var(--accent-red-hover);
}

/* =====================================================
   LIGHTBOX MODAL STYLING
   ===================================================== */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-container {
  max-width: 90%;
  max-height: 85%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.lightbox-content {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  color: #f1f5f9;
  font-size: 38px;
  font-weight: 300;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: scale(1.05);
}

.lightbox-caption {
  font-family: var(--font-sans);
  color: #cbd5e1;
  font-size: 13px;
  text-align: center;
  max-width: 500px;
  line-height: 1.4;
}

.lightbox-actions {
  display: flex;
  gap: 12px;
}

.lightbox-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: #0f172a;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

.lightbox-btn:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
  box-shadow: 0 12px 20px -3px rgba(0,0,0,0.4);
}

.lightbox-btn svg {
  color: #22c55e; /* Google Drive color accent */
}

