/* ========================================
   Herbalife Auto Learning - Modern Styles
   ======================================== */

/* CSS Variables - Design System */
:root {
  /* Colors - Herbalife Brand */
  --primary: #7ac143;
  --primary-dark: #467700;
  --primary-light: #9dd662;
  --accent: #00a651;
  --error: #e74c3c;
  --warning: #f39c12;
  --success: #27ae60;
  
  /* Neutral Colors */
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --text-light: #95a5a6;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --border-color: #e1e8ed;
  
  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.15);
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

body {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 0;
}

/* Mobile-first: No padding on mobile */
@media (min-width: 568px) {
  body {
    padding: var(--space-md);
  }
}

/* Typography */
h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

@media (min-width: 568px) {
  h1 {
    font-size: 2rem;
    letter-spacing: -0.5px;
  }
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-sm);
}

p {
  margin: 0 0 var(--space-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-fast);
  font-weight: 500;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* Layout Containers */
.testbox {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
  max-width: 680px;
  margin: 0 auto;
}

form {
  width: 100%;
  background: var(--bg-primary);
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  animation: slideUp 0.4s ease-out;
  min-height: 100vh;
}

/* Desktop: Add spacing and styling */
@media (min-width: 568px) {
  .testbox {
    padding: var(--space-lg) var(--space-md);
    min-height: auto;
  }
  
  form {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-height: auto;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Banner Styles */
.banner {
  position: relative;
  height: 140px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  background-image: linear-gradient(rgba(70, 119, 0, 0.7), rgba(122, 193, 67, 0.7)), 
                    url("/public/images/myhl-splashpage-global-background.jpg");
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--space-md);
  margin: 0;
}

.banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
  pointer-events: none;
}

.banner h1 {
  position: relative;
  z-index: 1;
  padding: 0 var(--space-sm);
}

.banner1 {
  position: relative;
  height: 100px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--space-md);
}

.banner1 h1 {
  position: relative;
  font-size: 1.5rem;
}

/* Desktop: Taller banners */
@media (min-width: 568px) {
  .banner {
    height: 200px;
  }
  
  .banner1 {
    height: 120px;
  }
  
  .banner1 h1 {
    font-size: 1.75rem;
  }
}

/* Content Area */
.item {
  position: relative;
  padding: 0.75rem 1rem;
}

.item:first-of-type {
  padding-top: 1rem;
}

.item:last-of-type {
  padding-bottom: 1rem;
}

.item > p:first-child {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-bottom: 0.375rem;
}

/* Desktop: More spacing */
@media (min-width: 568px) {
  .item {
    padding: var(--space-md);
  }
  
  .item:first-of-type {
    padding-top: var(--space-lg);
  }
  
  .item:last-of-type {
    padding-bottom: var(--space-lg);
  }
  
  .item > p:first-child {
    font-size: 0.95rem;
    margin-bottom: var(--space-xs);
  }
}

/* Form Elements */
input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Desktop: More padding */
@media (min-width: 568px) {
  input,
  select,
  textarea {
    padding: 0.875rem 1rem;
  }
}

input::placeholder,
textarea::placeholder {
  color: var(--text-light);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(122, 193, 67, 0.1);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--primary-light);
}

input[type="password"] {
  letter-spacing: 0.1em;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

select {
  cursor: pointer;
  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='%237f8c8d' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* Input Icons */
.item i {
  position: absolute;
  right: calc(var(--space-md) + 1rem);
  top: calc(var(--space-md) + 3rem);
  color: var(--text-light);
  pointer-events: none;
}

[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Radio Buttons - Modern Style */
input[type=radio] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

label.radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: var(--space-xs) var(--space-md) var(--space-xs) 0;
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  user-select: none;
  padding-left: 32px; /* Space for radio button */
}

label.radio:hover {
  background: var(--bg-secondary);
}

.question span {
  margin-left: 30px;
}

label.radio:before {
  content: "";
  position: absolute;
  left: var(--space-xs);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--bg-primary);
  transition: var(--transition);
  flex-shrink: 0;
}

input[type=radio]:checked + label:before {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(122, 193, 67, 0.1);
}

label.radio:hover:before {
  border-color: var(--primary-light);
}

label.radio:after {
  content: "";
  position: absolute;
  left: calc(var(--space-xs) + 7px);
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}

input[type=radio]:checked + label:after {
  transform: translateY(-50%) scale(1);
}

/* Checkbox Style */
input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
  margin: 0;
}

input[type=checkbox]:hover {
  border-color: var(--primary-light);
}

input[type=checkbox]:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(122, 193, 67, 0.1);
}

input[type=checkbox]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

/* Buttons - Modern Style */
.btn-block {
  padding: 0.75rem 1rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
}

/* Desktop: More spacing */
@media (min-width: 568px) {
  .btn-block {
    padding: 0 var(--space-md) var(--space-md);
    gap: var(--space-sm);
  }
}

button {
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Desktop: Bigger buttons */
@media (min-width: 568px) {
  button {
    min-height: 48px;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

button:hover::before {
  left: 100%;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Button Variants */
button#viewHistory,
button.btn-secondary {
  background: var(--bg-primary);
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}

button#viewHistory:hover,
button.btn-secondary:hover {
  background: var(--primary);
  color: white;
}

button.btn-outline {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  box-shadow: none;
}

button.btn-outline:hover {
  background: var(--bg-secondary);
  border-color: var(--primary);
  color: var(--primary);
}

/* Desktop: Side by side buttons */
@media (min-width: 568px) {
  .btn-block {
    flex-direction: row;
    justify-content: center;
  }
  
  button {
    width: auto;
    min-width: 180px;
  }
}

/* Tables - Modern Style */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

thead {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

thead td {
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.3px;
  padding: 0.75rem 0.5rem;
  border: none;
}

tbody td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: var(--transition-fast);
}

/* Row status colors - Background đậm hơn + border-right */
tbody tr.row-success {
  background: linear-gradient(to right, #c8e6c9 0%, #e8f5e9 100%);
  border-right: 4px solid #4caf50;
}

tbody tr.row-success:hover {
  background: linear-gradient(to right, #a5d6a7 0%, #c8e6c9 100%);
  border-right-color: #388e3c;
}

/* Success row with click handler - show indicator */
tbody tr.row-success[onclick]:hover::after {
  content: '📸 Double click để tải ảnh';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--primary-dark);
  font-weight: 600;
  background: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

tbody tr.row-error {
  background: linear-gradient(to right, #ffcdd2 0%, #ffebee 100%);
  border-right: 4px solid #f44336;
}

tbody tr.row-error:hover {
  background: linear-gradient(to right, #ef9a9a 0%, #ffcdd2 100%);
  border-right-color: #d32f2f;
}

/* Admin: Clickable error rows (can remove) */
tbody tr.can-remove {
  cursor: pointer;
  position: relative;
}

tbody tr.can-remove:hover {
  background: linear-gradient(to right, #ef5350 0%, #e57373 100%);
  border-right-color: #c62828;
  box-shadow: inset 0 0 0 1px rgba(211, 47, 47, 0.3);
}

tbody tr.can-remove:hover::after {
  content: '🗑️ Click để xóa';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: #c62828;
  font-weight: 600;
  background: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

tbody tr:not(.row-success):not(.row-error):hover {
  background: var(--bg-secondary);
}

td {
  text-align: left;
  word-break: break-word;
}

/* STT column - wider to prevent wrapping */
td:first-child {
  width: 50px;
  text-align: center;
  font-weight: 600;
  color: var(--text-primary);
}

/* Account column - 2 lines (email + icon, name) */
td:nth-child(2) {
  line-height: 1.4;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
}

td:nth-child(2) .email {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.8125rem;
  word-break: break-all;
  margin-bottom: 0.125rem;
}

td:nth-child(2) .couple-icon {
  display: inline-block;
  margin-left: 0.375rem;
  font-size: 0.875rem;
  vertical-align: middle;
}

td:nth-child(2) .name {
  display: block;
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 400;
}

/* Date column - separate column */
td:nth-child(3) {
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  width: 90px;
  vertical-align: middle;
}

/* Desktop: Bigger text and spacing */
@media (min-width: 568px) {
  table {
    font-size: 0.875rem;
  }
  
  thead td {
    font-size: 0.75rem;
    padding: var(--space-sm) var(--space-xs);
  }
  
  tbody td {
    padding: var(--space-sm) var(--space-xs);
    font-size: 0.875rem;
  }
  
  td:first-child {
    width: 60px;
  }
  
  td:nth-child(2) .email {
    font-size: 0.875rem;
  }
  
  td:nth-child(2) .name {
    font-size: 0.75rem;
  }
  
  td:nth-child(3) {
    font-size: 0.8125rem;
    width: 100px;
  }
}

/* Table Container */
.item > div[style*="overflow"] {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* Status Icons - Modern Style */
.completed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-size: 1rem;
  font-weight: bold;
  box-shadow: var(--shadow-sm);
}

.completed.clickable {
  cursor: pointer;
  transition: var(--transition);
}

.completed.clickable:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
  background: #229954;
}

.error {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--error);
  color: white;
  font-size: 1rem;
  font-weight: bold;
  box-shadow: var(--shadow-sm);
}

/* Helper Classes */
.text-center {
  text-align: center;
}

.help-key {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  margin: 0.375rem 0;
  font-style: italic;
  display: block;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  line-height: 1.4;
}

/* Desktop: Bigger text */
@media (min-width: 568px) {
  .help-key {
    font-size: 0.875rem;
    padding: var(--space-sm);
    margin: var(--space-xs) 0;
  }
}

.help-key[style*="color: red"] {
  color: var(--error) !important;
  background: #fef5f5;
  border-left-color: var(--error);
}

.warning-count {
  color: white;
  font-weight: 600;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--error) 0%, #c0392b 100%);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  display: none;
  margin: var(--space-md);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.warning-login {
  color: white;
  font-weight: 600;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--error) 0%, #c0392b 100%);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin: var(--space-md);
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* Info Box/Stats */
.item > p:has(#count),
.item > p:has(span) {
  background: var(--bg-secondary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.item > p > span#count,
.item > p > span {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Desktop: Bigger stats */
@media (min-width: 568px) {
  .item > p:has(#count),
  .item > p:has(span) {
    padding: var(--space-md);
    font-size: 1rem;
  }
  
  .item > p > span#count,
  .item > p > span {
    font-size: 1.25rem;
  }
}

/* Login Mode */
.login-mode {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.login-mode label {
  flex: 1;
  min-width: calc(50% - var(--space-sm) / 2);
  display: inline-flex;
  align-items: center;
}

.login-mode input[type="radio"] {
  width: auto;
  margin-right: var(--space-xs);
}

.mode-email {
  display: none;
}

/* Radio and checkbox inputs */
.loginMethod, 
.runningMode {
  width: auto;
  margin-left: var(--space-xs);
}

/* Log Container (for auto.html) */
#log {
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  overflow-y: auto;
  max-height: 500px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

#log p {
  margin: 0.25rem 0;
  color: #d4d4d4;
  word-break: break-all;
}

#log p[style*="color: green"],
#log p[style*="color: #008000"] {
  color: #4ec9b0 !important;
}

#log p[style*="color: red"],
#log p[style*="color: #ff0000"] {
  color: #f48771 !important;
}

/* Contact Info */
#contact-info {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: var(--bg-secondary);
  border-radius: 0;
  border-top: 3px solid var(--primary);
}

#contact-info p {
  margin: 0.375rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

#contact-info p:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

#contact-info a {
  color: var(--primary);
  font-weight: 600;
}

/* Desktop: More spacing */
@media (min-width: 568px) {
  #contact-info {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
  }
  
  #contact-info p {
    margin: var(--space-xs) 0;
    font-size: 0.9rem;
  }
}

/* Responsive Design */
@media (min-width: 568px) {
  .name-item,
  .city-item {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
  }

  .name-item input,
  .city-item input {
    flex: 1;
    min-width: calc(50% - var(--space-md) / 2);
  }

  .city-item select {
    flex: 1;
    min-width: calc(50% - var(--space-md) / 2);
  }
  
  h1 {
    font-size: 2rem;
  }
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fade in animation for dynamic content */
.fade-in {
  animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Focus visible for accessibility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
