/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  line-height: 1.6;
  color: #333;
}

/* Main wrapper for centering */
.main-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

/* Login container */
.login-container,
.install-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Login header */
.login-header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  background: linear-gradient(45deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

.login-header p {
  color: #666;
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.install-container {
  text-align: left;
  max-width: 640px;
}

.install-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.install-header p {
  color: #4b5563;
  font-size: 1rem;
  margin-bottom: 20px;
}

.install-steps,
.install-env,
.install-panel {
  margin-bottom: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px 22px;
  background: #f8fafc;
}

.install-manual {
  margin-bottom: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px 22px;
  background: #fff7ed;
}

.install-manual pre {
  margin: 12px 0;
  background: #111827;
  color: #f8fafc;
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.85rem;
}

.php-config {
  margin-bottom: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px 22px;
  background: #fff;
  text-align: left;
}

.php-config textarea {
  width: 100%;
  min-height: 120px;
  border-radius: 12px;
  border: 1px solid #cbd5f5;
  padding: 12px;
  font-family: 'Consolas', 'Segoe UI', monospace;
  margin-bottom: 12px;
  resize: vertical;
}

.php-config button {
  padding: 10px 18px;
  font-size: 0.95rem;
  width: auto;
}

.php-config-result {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #334155;
}

.install-debug {
  margin-bottom: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px 22px;
  background: #fff;
  text-align: left;
}

.debug-log {
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  font-family: 'Consolas', 'Segoe UI', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.debug-log .log-entry {
  margin-bottom: 8px;
}

.debug-log .log-entry strong {
  font-weight: 600;
  color: #a5b4fc;
}

.install-steps ol {
  padding-left: 18px;
  color: #1f2937;
}

.install-steps li {
  margin-bottom: 10px;
  line-height: 1.5;
}

.install-env pre {
  background: #1f2937;
  color: #f8fafc;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.9rem;
}

.muted {
  color: #475569;
  font-size: 0.85rem;
}

/* Form styles */
.login-form {
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

input, select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: #fff;
  outline: none;
}

input:focus, select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-2px);
}

input::placeholder {
  color: #999;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
}

/* Login button */
.login-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

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

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

/* Login footer */
.login-footer {
  border-top: 1px solid #e1e5e9;
  padding-top: 20px;
  margin-top: 20px;
}

.login-footer p {
  color: #888;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .main-wrapper {
    padding: 15px;
  }
  
  .login-container,
  .install-container {
    padding: 30px 25px;
    border-radius: 15px;
    max-width: 360px;
  }
  
  .login-header h1 {
    font-size: 2.2rem;
  }
  
  .login-header p {
    font-size: 0.9rem;
  }
  
  input, select, .login-btn {
    padding: 12px 14px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

@media (max-width: 480px) {
  .main-wrapper {
    padding: 10px;
  }
  
  .login-container {
    padding: 25px 20px;
    border-radius: 12px;
  }
  
  .login-header h1 {
    font-size: 2rem;
  }
  
  .form-group {
    margin-bottom: 18px;
  }
  
  input, select, .login-btn {
    padding: 14px 12px;
  }
}

/* Animation for form elements */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-container {
  animation: slideUp 0.6s ease-out;
}

/* Loading state for button */
.login-btn.loading {
  pointer-events: none;
}

.login-btn.loading span {
  opacity: 0;
}

.login-btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid transparent;
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Additional styles for enhanced user forms */
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: #fff;
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
  min-height: 80px;
}

textarea:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-2px);
}

small {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 5px;
  display: block;
  font-style: italic;
}

.form-group small {
  margin-top: 5px;
}

/* Enhanced user item styling */
.user-item .user-details {
  line-height: 1.5;
}

.user-item .user-details div {
  margin-bottom: 4px;
}

.user-item .user-details div:last-child {
  margin-bottom: 0;
}

/* Enhanced site badge */
.site-badge {
  display: inline-block;
  margin: 2px;
  white-space: nowrap;
}

/* Form validation styling */
.form-group.error input,
.form-group.error select,
.form-group.error textarea {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-group.success input,
.form-group.success select,
.form-group.success textarea {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Shared dashboard layout */
.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  background: #f8fafc;
  min-height: 100vh;
}

.dashboard-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 28px 32px;
  border-radius: 18px;
  margin-bottom: 36px;
  box-shadow: 0 18px 40px rgba(102, 126, 234, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.dashboard-header .header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dashboard-header .brand-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.dashboard-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.dashboard-header p {
  margin: 6px 0 0 0;
  opacity: 0.9;
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  color: rgba(255, 255, 255, 0.9);
}

.welcome-stack {
  text-align: right;
  font-size: 0.95rem;
}

.welcome-stack .welcome-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.welcome-stack .welcome-label {
  display: block;
  opacity: 0.85;
  font-size: 0.9rem;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  padding: 9px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

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

.dashboard-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  border: 1px solid #e5e7eb;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 2px solid #f1f5f9;
}

.card-header i {
  font-size: 1.3rem;
  color: #667eea;
}

.card-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #1e293b;
  font-weight: 600;
}

.user-dashboard {
  max-width: 960px;
}

.dashboard-stack {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.status-section {
  text-align: center;
  margin-bottom: 28px;
}

.status-indicator {
  font-size: 4rem;
  margin-bottom: 18px;
  transition: color 0.3s ease;
}

.status-indicator.clocked-out {
  color: #ef4444;
}

.status-indicator.clocked-in {
  color: #10b981;
}

.status-text {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1e293b;
}

.status-details {
  color: #64748b;
  font-size: 1rem;
}

.location-status {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: center;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-weight: 500;
}

.location-status.valid {
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.location-status.invalid {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.clock-buttons {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
}

.clock-btn {
  padding: 16px 30px;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
  justify-content: center;
  color: #fff;
}

.clock-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.clock-in-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.28);
}

.clock-in-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(16, 185, 129, 0.35);
}

.clock-out-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.28);
}

.clock-out-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(239, 68, 68, 0.35);
}

.recent-logs {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.log-item {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.log-item.clock-in {
  border-left: 4px solid #10b981;
}

.log-item.clock-out {
  border-left: 4px solid #ef4444;
}

.log-details {
  flex: 1;
  color: #475569;
}

.log-action {
  background: #e0e7ff;
  color: #4338ca;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}

.log-action.out {
  background: #fee2e2;
  color: #dc2626;
}

.log-time {
  color: #334155;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.card-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 0.95rem;
}

.data-summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 18px;
}

.data-summary-item {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 18px;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.05);
}

.data-summary-item .summary-count {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: #4f46e5;
  margin-bottom: 6px;
}

.data-summary-item .summary-label {
  color: #475569;
  font-size: 0.9rem;
  font-weight: 600;
}

.data-summary-item .summary-subtext {
  display: block;
  margin-top: 6px;
  color: #94a3b8;
  font-size: 0.8rem;
}

.export-section-heading {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin-top: 8px;
  margin-bottom: 16px;
}

.export-button-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, #4c6ef5, #5a67d8);
  box-shadow: 0 12px 24px rgba(76, 110, 245, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.export-btn.secondary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 12px 24px rgba(14, 165, 233, 0.25);
}

.export-btn.ghost {
  background: #fff;
  color: #312e81;
  border: 1px solid rgba(99, 102, 241, 0.25);
  box-shadow: 0 12px 24px rgba(99, 102, 241, 0.15);
}

.export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(76, 110, 245, 0.28);
}

.export-btn.secondary:hover {
  box-shadow: 0 16px 32px rgba(14, 165, 233, 0.28);
}

.export-btn.ghost:hover {
  box-shadow: 0 16px 32px rgba(99, 102, 241, 0.22);
}

.card-note {
  margin-top: 14px;
  color: #64748b;
  font-size: 0.85rem;
}

.import-section {
  margin-top: 20px;
}

.import-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  min-height: 40px;
  display: none;
}

.import-status.success {
  display: block;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.import-status.error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.import-status.info {
  display: block;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #3b82f6;
}

.storage-mode-badge {
  margin-top: 16px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.storage-mode-badge.local {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.storage-mode-badge.server {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.storage-mode-badge.cloud {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #3b82f6;
}

.storage-mode-badge::before {
  content: '●';
  font-size: 1.2em;
}

@media (max-width: 900px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-stack {
    text-align: left;
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    padding: 24px 16px 40px;
  }

  .dashboard-card {
    padding: 24px 22px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .clock-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .clock-btn {
    width: 100%;
  }

  .log-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .log-time {
    text-align: left;
  }

  .export-button-grid {
    grid-template-columns: 1fr;
  }
}