/**
 * Khelwade Hospital - Staff Daily Attendance & Dynamic Payroll System
 * Premium Healthcare Theme Design System
 */

:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --primary-gradient: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  --accent: #0ea5e9;
  --success: #10b981;
  --success-dark: #059669;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #38bdf8;
  
  --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 0 20px rgba(2, 132, 199, 0.25);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* App Wrapper */
.app-container {
  width: 100%;
  max-width: 1100px;
  min-height: 100vh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: relative;
}

@media (min-width: 768px) {
  body {
    padding: 20px 10px;
    background: #e2e8f0;
  }
  .app-container {
    min-height: calc(100vh - 40px);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.3s ease-out;
  pointer-events: auto;
}

.toast.success { background: #065f46; color: #ecfdf5; border-left: 5px solid var(--success); }
.toast.error { background: #991b1b; color: #fef2f2; border-left: 5px solid var(--danger); }
.toast.info { background: #075985; color: #f0f9ff; border-left: 5px solid var(--primary); }
.toast.warning { background: #92400e; color: #fffbeb; border-left: 5px solid var(--warning); }

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

/* Header */
.app-header {
  background: var(--primary-gradient);
  color: #ffffff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.brand-title h1 {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-title p {
  font-size: 0.75rem;
  opacity: 0.88;
  font-weight: 500;
}

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

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.user-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.user-profile h2 {
  font-size: 0.96rem;
  font-weight: 700;
}

.user-profile span {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.live-clock {
  text-align: right;
}

.live-time {
  font-size: 0.98rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.live-date {
  font-size: 0.7rem;
  opacity: 0.85;
}

/* Main Content */
.app-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  padding-bottom: 85px;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.view-section.active {
  display: block;
}

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

/* Login View */
.login-card {
  max-width: 420px;
  margin: 40px auto;
  background: #ffffff;
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.login-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Forms & Inputs */
.input-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-field, .select-field {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  transition: var(--transition);
}

.input-field:focus, .select-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn-primary {
  width: 100%;
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

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

.btn-secondary-sm {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-secondary-sm:hover {
  background: #e2e8f0;
}

.btn-success-sm {
  background: var(--success);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-success-sm:hover {
  background: var(--success-dark);
}

/* Dashboard Cards */
.duty-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.badge-duty {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.badge-duty.flex { background: #e0e7ff; color: #3730a3; }
.badge-duty.sched { background: #dcfce7; color: #166534; }

.gps-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gps-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gps-badge {
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-block;
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

.gps-badge.acquiring { background: #fef3c7; color: #92400e; }
.gps-badge.inside { background: #dcfce7; color: #166534; }
.gps-badge.outside { background: #fee2e2; color: #991b1b; }

/* Status & Punch Button */
.status-card {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  transition: var(--transition);
}

.status-card.punched-in {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}

.status-card.punched-out {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff5f5 0%, #ffffff 100%);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.status-badge.in { background: #dcfce7; color: #15803d; }
.status-badge.out { background: #fee2e2; color: #b91c1c; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.punch-btn-container {
  margin: 20px 0 10px;
  display: flex;
  justify-content: center;
}

.punch-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #ffffff;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
}

.punch-btn svg {
  width: 44px;
  height: 44px;
}

.punch-btn #punch-btn-text {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.punch-in-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.punch-in-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 30px rgba(16, 185, 129, 0.5);
}

.punch-out-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
}

.punch-out-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 30px rgba(239, 68, 68, 0.5);
}

.session-timer {
  margin-top: 14px;
  background: rgba(0,0,0,0.05);
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}

.session-timer strong {
  color: var(--primary-dark);
  font-weight: 800;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Info Tiles */
.shift-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-tile {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.info-tile span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.info-tile p {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

/* History & Stats */
.history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-card span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-top: 2px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

/* Manager Portal Tabs */
.sub-tabs-nav {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow-x: auto;
}

.sub-tab-btn {
  flex: 1;
  min-width: 130px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.sub-tab-btn.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.card-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.filter-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.mgr-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mgr-stat-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.mgr-stat-box .val {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.mgr-stat-box .lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.data-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

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

.data-table tfoot td {
  background: #f8fafc;
  font-weight: 800;
  border-top: 2px solid var(--border);
}

/* Payroll Specific Styles */
.payroll-input {
  width: 75px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  text-align: right;
}

.payroll-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #f0f9ff;
}

.payroll-summary-banner {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.payroll-summary-item span {
  font-size: 0.72rem;
  opacity: 0.85;
  text-transform: uppercase;
  font-weight: 600;
}

.payroll-summary-item h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 2px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease-out;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

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

.shift-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}

.preset-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.preset-pill:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Bottom Navigation */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1100px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px;
  z-index: 40;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.04);
}

@media (min-width: 768px) {
  .app-nav {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
  }
}

.nav-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-light);
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 14px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}
