/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --blue-dark: #1565a8;
  --blue-mid: #2196d4;
  --blue-light: #34c6eb;
  --blue-pale: #e8f4fd;
  --green: #6abf4b;
  --white: #ffffff;
  --gray-100: #f5f7fa;
  --gray-200: #e4e8ec;
  --gray-400: #a0aab4;
  --gray-600: #5a6872;
  --gray-800: #2d3436;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(21, 101, 168, 0.12);
  --shadow-lg: 0 16px 48px rgba(21, 101, 168, 0.18);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ===== Header ===== */
header {
  position: relative;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 50%, var(--blue-light) 100%);
  padding: 0;
  overflow: hidden;
}

.header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.header-eye-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.header-eye-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.18;
}

.logo-image a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-image img {
  height: 44px;
  width: auto;
}

.header-title {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.header-wave {
  display: block;
  width: 100%;
  margin-top: -2px;
  line-height: 0;
}

.header-wave img {
  width: 100%;
  height: auto;
  display: block;
}

/* SVG wave fallback */
.header-wave svg {
  display: block;
  width: 100%;
  height: 60px;
}

/* ===== Main Container ===== */
.main-container {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

#imgForm {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ===== Auth Box ===== */
.form-group.auth-box {
  position: relative;
}

.auth-box input[type="text"] {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.auth-box input[type="text"]:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 4px rgba(33, 150, 212, 0.12);
}

.auth-box::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-image: url('../../images/lock.png');
  background-size: contain;
  background-repeat: no-repeat;
  z-index: 1;
}

.warn-text {
  color: #e74c3c;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  display: block;
}

.warn-text.active {
  display: none;
}

/* ===== Drop Zones Container ===== */
.drop-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.drop-container > div {
  position: relative;
}

/* ===== Drop Zone ===== */
.drop-zone {
  position: relative;
  min-height: 220px;
  border-radius: var(--radius);
  border: 3px dashed var(--gray-200);
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  padding: 24px;
}

.drop-zone:hover {
  border-color: var(--blue-mid);
  background: var(--blue-pale);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.drop-zone--over {
  border-color: var(--blue-light);
  background: var(--blue-pale);
  border-style: solid;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.drop-zone__prompt {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--gray-400);
  font-size: 0.9rem;
  text-align: center;
  pointer-events: none;
}

.drop-zone__prompt.active {
  display: flex;
}

.drop-zone__prompt::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  background-image: url('../../images/upload-file.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
}

.drop-zone__input {
  display: none;
}

/* Thumbnail */
.drop-zone__thumb {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius) - 3px);
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.drop-zone__thumb::after {
  content: attr(data-label);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: var(--white);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Close button */
.close-btn {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(231, 76, 60, 0.9);
  color: var(--white);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
  align-items: center;
  justify-content: center;
}

.close-btn.active {
  display: flex;
}

.close-btn:hover {
  background: #c0392b;
  transform: scale(1.1);
}

/* ===== Drop zone labels ===== */
.drop-label {
  text-align: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--gray-400);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== Analysis Result ===== */
.result-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-height: 60px;
}

.ikey-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ikey-title::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background-image: url('../../images/logo.png');
  background-size: contain;
  background-repeat: no-repeat;
}

.ikey-response {
  color: var(--gray-600);
  font-size: 0.95rem;
  line-height: 1.6;
  word-break: break-word;
  min-height: 1.6em;
}

/* ===== Buttons ===== */
.button-row {
  display: flex;
  gap: 16px;
}

.form-group input[type="submit"],
.btn-primary {
  flex: 1;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-transform: none;
  letter-spacing: 0.3px;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 60%, var(--blue-light) 100%);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(33, 150, 212, 0.3);
}

.form-group input[type="submit"]:hover,
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(33, 150, 212, 0.4);
}

.form-group input[type="submit"]:active,
.btn-primary:active {
  transform: translateY(0);
}

.form-group input[type="submit"]:disabled,
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.form-group input[type="button"],
.btn-secondary {
  flex: 1;
  padding: 14px 32px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: var(--white);
  color: var(--gray-600);
}

.form-group input[type="button"]:hover,
.btn-secondary:hover {
  border-color: var(--blue-mid);
  color: var(--blue-mid);
  background: var(--blue-pale);
}

/* ===== Progress / Meter ===== */
.meter {
  display: none;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-top: -8px;
}

.meter.active {
  display: block;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue-light));
  transition: width 0.8s ease;
  position: relative;
}

.meter > span::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== Processing overlay ===== */
.processing-overlay {
  display: none;
  position: relative;
  text-align: center;
  padding: 32px 24px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.processing-overlay.active {
  display: block;
}

.processing-overlay img {
  width: 120px;
  height: auto;
  animation: pulse 2s ease-in-out infinite;
}

.processing-text {
  margin-top: 16px;
  font-size: 1rem;
  color: var(--blue-mid);
  font-weight: 500;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ===== Footer ===== */
footer {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 50%, var(--blue-light) 100%);
  padding: 20px 40px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-logo img {
  height: 28px;
  width: auto;
  opacity: 0.9;
}

.footer-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.8rem;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--white);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header-inner {
    padding: 16px 20px;
  }

  .logo-image img {
    height: 32px;
  }

  .header-title {
    font-size: 0.9rem;
  }

  .main-container {
    padding: 24px 16px 40px;
  }

  .drop-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .drop-zone {
    min-height: 160px;
  }

  .button-row {
    flex-direction: column;
    gap: 12px;
  }

  .footer-inner {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .footer-links {
    gap: 16px;
  }
}
