/* Reset and Base Styles */
* { box-sizing: border-box; }

:root {
  --primary-color: #000000;
  --primary-dark: #000000;
  --secondary-color: #000000;
  --success-color: #000000;
  --danger-color: #000000;
  --warning-color: #000000;
  --info-color: #000000;
  --gray-50: #ffffff;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d4d4d4;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body { 
  margin: 0; 
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; 
  background: #ffffff;
  min-height: 100vh;
  color: var(--gray-800); 
  line-height: 1.6;
}

/* Header Styles */
header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Dropdown Menu */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown .dropbtn {
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.arrow {
  border: solid var(--gray-500);
  border-width: 0 2px 2px 0;
  display: inline-block;
  padding: 3px;
  transform: rotate(45deg);
  transition: all 0.2s ease;
}

.dropdown:hover .arrow {
  transform: rotate(225deg);
  border-color: #000000;
}

.dropdown:hover .dropbtn, .dropdown .dropbtn.active {
  background: var(--gray-100);
  color: #000000;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #ffffff;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 101;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  visibility: hidden;
  top: 100%;
  left: 50%;
  margin-left: -90px; /* Half of min-width */
  padding-top: 8px; /* Creates space to avoid accidental mouse-out */
}

.dropdown-content a {
  color: var(--gray-700);
  padding: 10px 16px;
  text-decoration: none;
  display: block;
  font-size: 14px;
}

.dropdown-content a:hover {
  background-color: var(--gray-100);
  color: #000000;
}

.dropdown:hover .dropdown-content {
  display: block;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

header h1 { 
  font-size: 20px;
  font-weight: 600;
  color: #000000;
  flex-shrink: 0;
}

nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-grow: 1;
}

nav a {
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

nav a:hover {
  background: var(--gray-100);
  color: #000000;
}

#auth-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-email {
  font-size: 14px;
  color: var(--gray-600);
  font-weight: 500;
}

/* Main Content */
main { 
  max-width: 1200px; 
  margin: 24px auto; 
  padding: 0 20px; 
  position: relative;
  z-index: 10; /* Ensure it's below the header */
}

/* Card Styles */
.card { 
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 24px; 
  border-radius: 16px; 
  box-shadow: var(--shadow-lg);
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

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

.card h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-800);
  border-bottom: 2px solid var(--gray-100);
  padding-bottom: 8px;
}

/* Grid Layouts */
.grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
  gap: 16px; 
}

.grid-2 { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); 
  gap: 20px; 
}

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

/* Form Elements */
label { 
  display: block; 
  font-size: 14px; 
  color: var(--gray-700); 
  margin-bottom: 12px; 
  font-weight: 500;
}

input, select, textarea { 
  width: 100%; 
  padding: 12px 16px; 
  border-radius: 8px; 
  border: 2px solid var(--gray-200); 
  outline: none; 
  font-size: 14px;
  transition: all 0.2s ease;
  background: white;
}

input:focus, select:focus, textarea:focus { 
  border-color: #000000; 
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

input::placeholder {
  color: var(--gray-400);
}

/* Button Styles */
button, .btn { 
  background: #000000;
  color: white; 
  border: none; 
  padding: 12px 20px; 
  border-radius: 8px; 
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 44px;
}

button:hover, .btn:hover { 
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  background: #333333;
}

button.secondary, .btn.secondary { 
  background: #737373;
}

button.secondary:hover, .btn.secondary:hover {
  background: #525252;
}

button.small { 
  padding: 8px 12px; 
  font-size: 12px; 
  min-height: 32px;
}

button:disabled { 
  opacity: 0.6; 
  cursor: not-allowed; 
  transform: none;
}

button:active, .btn:active {
  transform: translateY(0);
}

.btn.outline {
  background: white;
  color: #000000;
  border: 2px solid #000000;
}

.btn.outline:hover {
  background: var(--gray-50);
  transform: translateY(-1px);
}

.btn.large {
  padding: 16px 24px;
  font-size: 16px;
  width: 100%;
  justify-content: center;
}

/* Toolbar */
.toolbar { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  margin-bottom: 16px; 
  flex-wrap: wrap;
}

.toolbar input {
  min-width: 200px;
  margin: 0;
}

/* Table Styles */
table { 
  width: 100%; 
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

thead {
  background: var(--gray-100);
}

th, td { 
  text-align: left; 
  padding: 12px 16px; 
  font-size: 14px;
}

th {
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
}

td {
  border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover {
  background: var(--gray-50);
}

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

/* Output/Pre Styles */
pre.output { 
  background: var(--gray-900);
  color: var(--gray-100); 
  padding: 16px; 
  border-radius: 8px; 
  max-height: 300px; 
  overflow: auto; 
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid var(--gray-700);
}

/* Message Styles */
.msg { 
  margin-left: 12px; 
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
}

.msg.success { color: var(--success-color); }
.msg.error { color: var(--danger-color); }
.msg.warning { color: var(--warning-color); }
.msg.info { color: var(--info-color); }

/* Dashboard Specific Styles */
.stat-item { 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  margin-bottom: 12px; 
  padding: 12px 0; 
  border-bottom: 1px solid var(--gray-100);
  transition: all 0.2s ease;
}

.stat-item:hover {
  background: var(--gray-50);
  margin: 0 -12px 12px -12px;
  padding: 12px;
  border-radius: 6px;
}

.stat-label { 
  font-size: 14px; 
  color: var(--gray-600); 
  font-weight: 500;
}

.stat-value { 
  font-size: 20px; 
  font-weight: 700; 
  color: #000000;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.action-buttons { 
  display: flex; 
  flex-direction: column; 
  gap: 12px; 
}

.action-buttons .btn { 
  text-align: center; 
  text-decoration: none; 
  padding: 14px 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.batch-actions { 
  display: flex; 
  flex-direction: column; 
  gap: 12px; 
}

.status-item { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 10px; 
  padding: 10px 0; 
  border-bottom: 1px solid var(--gray-100);
}

.status-label { 
  font-size: 14px; 
  color: var(--gray-600); 
  font-weight: 500;
}

.status-indicator { 
  font-size: 14px; 
  font-weight: 600;
}

/* Login Page Specific */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
}

.login-card {
  max-width: 400px;
  width: 100%;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.card {
  animation: slideIn 0.4s ease-out;
}

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

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

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

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.page-loader.active {
  opacity: 1;
  visibility: visible;
}

.page-loader .spinner {
  border: 4px solid var(--gray-200);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
  header, footer {
    padding: 12px 16px;
    flex-direction: column;
    gap: 8px;
  }
  
  header h1 {
    font-size: 20px;
  }
  
  main {
    margin: 16px auto;
    padding: 0 12px;
  }
  
  .card {
    padding: 16px;
    margin-bottom: 16px;
  }
  
  .grid, .grid-2, .grid-3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .toolbar input {
    min-width: auto;
  }
  
  .action-buttons {
    gap: 8px;
  }
  
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 12px;
    border-radius: 12px;
  }
  
  button, .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  input, select {
    padding: 10px 12px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Focus and Accessibility */
button:focus, .btn:focus, input:focus, select:focus {
  outline: 2px solid #000000;
  outline-offset: 2px;
}


/* SMS Distribution (Vouchers) */
#participant-selection {
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  padding: 12px;
  border-radius: 8px;
}

.checkbox-container input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

#available-tags {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  padding: 4px;
  background: white;
}

#participant-list-container {
  max-height: 320px;
  overflow-y: auto;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  background: white;
}

#participant-list-container > div:hover {
  background: var(--gray-100);
}

#selection-status {
  font-weight: 600;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.switch input { display: none; }

.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--gray-300);
  transition: .2s;
  border-radius: 34px;
}

.switch .slider:before {
  position: absolute;
  content: "";
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .slider {
  background-color: var(--primary-color);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}
