/* ==================== VARIABLES ==================== */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16162a;
  --bg-hover: #252545;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b80;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-lg: 20px;
}

/* ==================== RESET & BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ==================== CUSTOMER PAGE ==================== */
.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    var(--bg-primary);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.main-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.logo {
  margin-bottom: 30px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 10px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.logo h1 {
  font-size: 24px;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-group input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
  transition: all 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

/* ==================== BUTTONS ==================== */
.btn-primary {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
}

.btn-loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==================== CODE DISPLAY ==================== */
.result-container {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
}

.code-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.code-digit {
  width: 50px;
  height: 60px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  font-family: 'Consolas', monospace;
  color: var(--accent-primary);
  transition: all 0.2s ease;
}

.code-digit.pop {
  transform: scale(1.1);
  border-color: var(--accent-primary);
}

.code-separator {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  margin: 0 4px;
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.timer-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.timer-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #34d399);
  border-radius: 3px;
  transition: width 1s linear, background 0.3s ease;
}

#timerText {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 35px;
}

/* ==================== ERROR MESSAGE ==================== */
.error-message {
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 14px;
}

/* ==================== FOOTER ==================== */
footer {
  margin-top: 30px;
}

.admin-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.admin-link:hover {
  color: var(--accent-primary);
}

/* ==================== SELLER CARD ==================== */
.seller-card {
  width: 100%;
  max-width: 420px;
  margin-top: 20px;
  padding: 24px;
}

.seller-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.seller-icon {
  font-size: 40px;
}

.seller-info h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.zalo-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.zalo-link:hover {
  color: #0068ff;
}

.products-list h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.products-list ul {
  list-style: none;
}

.products-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.products-list li:last-child {
  border-bottom: none;
}

.product-name {
  font-size: 14px;
  color: var(--text-primary);
}

.product-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 10px;
  border-radius: 6px;
}

/* ==================== ADMIN PAGE ==================== */
.admin-body {
  background: var(--bg-primary);
}

.admin-container {
  min-height: 100vh;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.admin-header h1 {
  font-size: 24px;
  font-weight: 600;
}

.btn-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.btn-link:hover {
  color: var(--accent-primary);
}

.admin-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.nav-btn {
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

.toolbar .btn-primary {
  width: auto;
}

.file-btn {
  cursor: pointer;
}

.search-box {
  margin-left: auto;
}

.search-box input {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  min-width: 250px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ==================== TABLES ==================== */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  font-size: 14px;
  color: var(--text-primary);
}

tr:hover {
  background: var(--bg-hover);
}

tr:last-child td {
  border-bottom: none;
}

.email-cell {
  font-weight: 500;
  color: var(--accent-primary);
}

.secret-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
}

.secret-hidden {
  color: var(--text-muted);
}

.code-cell .live-code {
  font-family: 'Consolas', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--success);
  letter-spacing: 2px;
}

.actions-cell {
  display: flex;
  gap: 4px;
}

.log-failed {
  background: rgba(239, 68, 68, 0.05);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.log-stats {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 14px;
}

.log-stats span {
  font-weight: 600;
  color: var(--accent-primary);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.empty-state .btn-primary {
  width: auto;
  display: inline-flex;
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
}

#accountForm {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-group small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.form-actions .btn-primary {
  width: auto;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .main-card {
    padding: 30px 20px;
  }

  .code-digit {
    width: 40px;
    height: 50px;
    font-size: 22px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    margin-left: 0;
  }

  .search-box input {
    width: 100%;
    min-width: auto;
  }

  .table-container {
    overflow-x: auto;
  }

  table {
    min-width: 600px;
  }

  .admin-nav {
    flex-wrap: wrap;
  }
}

/* ==================== LOGIN OVERLAY ==================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}