/* ============================================
   Aayatan Veda HR — Warm Earthy Theme
   Mobile-first responsive design
   ============================================ */

:root {
  /* Warm earthy palette */
  --primary: #B85C38;          /* Terracotta */
  --primary-dark: #8B3A2A;     /* Deep terracotta */
  --primary-light: #E0915C;    /* Light terracotta */
  --accent: #D4A853;           /* Gold */
  --accent-light: #F0D690;     /* Light gold */
  --bg: #FFF8F0;               /* Warm cream */
  --bg-card: #FFFFFF;          /* White cards */
  --bg-input: #FFF5EB;         /* Warm input bg */
  --text: #3D2B1F;             /* Dark brown */
  --text-light: #7A6555;       /* Muted brown */
  --text-muted: #A89585;       /* Very light brown */
  --border: #E8D5C4;           /* Warm border */
  --success: #5A8F5A;          /* Earthy green */
  --danger: #C0392B;           /* Deep red */
  --warning: #D4A853;          /* Gold (reuse accent) */
  --info: #5B7FA5;             /* Dusty blue */

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-xxl: 2rem;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(61,43,31,0.08);
  --shadow-md: 0 4px 12px rgba(61,43,31,0.1);
  --shadow-lg: 0 8px 24px rgba(61,43,31,0.12);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 50%;
}

/* ============ RESET & BASE ============ */

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============ UTILITY CLASSES ============ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { justify-content: center; align-items: center; }
.flex-between { justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* ============ LOGIN PAGE ============ */

.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: linear-gradient(135deg, #FFF8F0 0%, #F5E6D3 100%);
}

.login-logo {
  width: 80px;
  height: 80px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
}

.login-logo span {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
}

.login-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-light);
  margin-bottom: var(--space-xl);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}

.login-card .form-group {
  margin-bottom: var(--space-lg);
}

.login-card label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: var(--space-sm);
}

.login-card select,
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color 0.2s;
}

.login-card select:focus,
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184,92,56,0.1);
}

.pin-input-group {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.pin-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: var(--font-size-xl);
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text);
  -webkit-text-security: disc;
}

.pin-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184,92,56,0.15);
  outline: none;
}

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(184,92,56,0.3);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success {
  background: var(--success);
  color: #fff;
}

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

.btn-full { width: 100%; }

.btn-sm {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}

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

/* ============ APP SHELL ============ */

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  min-height: 56px;
}

.top-bar-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.top-bar-subtitle {
  font-size: var(--font-size-xs);
  opacity: 0.8;
}

.top-bar-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.top-bar-actions button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-size-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Main content area */
.main-content {
  flex: 1;
  padding: var(--space-md);
  padding-bottom: 80px; /* space for bottom nav */
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  box-shadow: 0 -2px 12px rgba(61,43,31,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: none;
  position: relative;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item .nav-icon {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.nav-item .nav-label {
  font-size: 0.65rem;
  font-weight: 600;
}

.nav-item .badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ============ CARDS ============ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
  border: 1px solid var(--border);
}

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

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

/* ============ SECTION HEADER ============ */

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

.section-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text);
}

/* ============ FORM ELEMENTS ============ */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: var(--space-xs);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184,92,56,0.1);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237A6555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input[type="time"] {
  font-family: var(--font);
}

/* ============ ATTENDANCE STATUS BUTTONS ============ */

.status-group {
  display: flex;
  gap: 4px;
}

.status-btn {
  width: 40px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.status-btn:active { transform: scale(0.95); }

.status-btn.active-P {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.status-btn.active-A {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.status-btn.active-H {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}

/* ============ ATTENDANCE ROW ============ */

.attendance-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}

.attendance-row-name {
  font-weight: 700;
  font-size: var(--font-size-md);
  margin-bottom: var(--space-sm);
}

.attendance-row-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.time-inputs {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.time-inputs input[type="time"] {
  width: 110px;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: var(--bg-input);
  color: var(--text);
}

.time-inputs input[type="time"]:focus {
  border-color: var(--primary);
  outline: none;
}

.hours-display {
  font-size: var(--font-size-sm);
  color: var(--text-light);
  font-weight: 600;
  min-width: 45px;
  text-align: center;
}

/* ============ TABLE ============ */

.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

thead th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--bg-input);
}

/* ============ STATUS BADGE ============ */

.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
}

.badge-paid { background: #E8F5E8; color: var(--success); }
.badge-unpaid { background: #FFF3E0; color: #D4843E; }
.badge-pending { background: #FFF8E1; color: #B8860B; }
.badge-approved { background: #E8F5E8; color: var(--success); }
.badge-rejected { background: #FFEBEE; color: var(--danger); }

/* ============ TOAST / NOTIFICATION ============ */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-8px);
}

/* ============ OFFLINE BANNER ============ */

.offline-banner {
  background: var(--danger);
  color: #fff;
  text-align: center;
  padding: 6px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  display: none;
}

.offline-banner.show { display: block; }

/* ============ LOADING ============ */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,248,240,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

/* ============ EMPTY STATE ============ */

.empty-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

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

/* ============ MODAL ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61,43,31,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-lg);
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-size-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
}

/* ============ DATE PICKER ============ */

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.date-nav input[type="date"] {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
}

.date-nav button {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  cursor: pointer;
  font-size: var(--font-size-md);
  color: var(--text);
}

/* ============ MONTH SELECTOR ============ */

.month-selector {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.month-selector select {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  background: var(--bg-card);
  color: var(--text);
}

/* ============ SUMMARY CARD ============ */

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.summary-card:hover { box-shadow: var(--shadow-md); }

.summary-card-name {
  font-weight: 700;
  font-size: var(--font-size-md);
  margin-bottom: var(--space-sm);
}

.summary-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.summary-stat {
  text-align: center;
}

.summary-stat-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--primary);
}

.summary-stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ============ RESPONSIVE ============ */

@media (min-width: 768px) {
  .main-content {
    padding: var(--space-lg);
    padding-bottom: 80px;
  }

  .modal {
    border-radius: var(--radius-lg);
    margin-bottom: auto;
    align-self: center;
  }

  .modal-overlay {
    align-items: center;
  }

  .attendance-row-controls {
    flex-wrap: nowrap;
  }

  .summary-card-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
