/* ============================================================
   Olin Group - Image Upload Application
   Color palette: Black #1a1a1a, White #ffffff, Yellow #FFD700/#F5C518
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #f4f4f5;
  color: #1a1a1a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* --- Header --- */
.header {
  background: #1a1a1a;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #F5C518;
  letter-spacing: 0.02em;
}

/* --- Main --- */
.main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 32px 16px 48px;
}

/* --- Card --- */
.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 600px;
}

/* --- Form Fields --- */
.field {
  margin-bottom: 22px;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.required {
  color: #e53e3e;
}

/* Shared input / select / textarea styles */
.field select,
.field input[type="number"],
.field textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1.5px solid #d4d4d8;
  border-radius: 8px;
  background: #ffffff;
  color: #1a1a1a;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.field select:disabled {
  background-color: #f4f4f5;
  color: #a1a1aa;
  cursor: not-allowed;
}

.field select:focus,
.field input[type="number"]:focus,
.field textarea:focus {
  outline: none;
  border-color: #F5C518;
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.2);
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

/* Remove number input spinners */
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field input[type="number"] {
  -moz-appearance: textfield;
}

/* --- Drop Zone --- */
.drop-zone {
  position: relative;
  border: 2px dashed #d4d4d8;
  border-radius: 10px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  user-select: none;
}

.drop-zone:hover {
  border-color: #F5C518;
  background: #fffef5;
}

.drop-zone.drag-over {
  border-color: #F5C518;
  background: rgba(245, 197, 24, 0.08);
  border-style: solid;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.drop-icon {
  width: 40px;
  height: 40px;
  color: #a1a1aa;
  margin-bottom: 6px;
  transition: color 0.2s;
}

.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  color: #F5C518;
}

.drop-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #52525b;
}

.drop-subtext {
  font-size: 0.8125rem;
  color: #71717a;
}

.browse-link {
  color: #F5C518;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.drop-hint {
  font-size: 0.75rem;
  color: #a1a1aa;
  margin-top: 2px;
}

/* File Count Badge */
.file-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #F5C518;
  color: #1a1a1a;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  animation: badge-pop 0.25s ease;
}

.file-badge[hidden] {
  display: none;
}

@keyframes badge-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Thumbnail Grid --- */
.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.thumbnail-grid:empty {
  margin-bottom: 0;
}

.thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f4f4f5;
  animation: thumb-in 0.25s ease;
}

@keyframes thumb-in {
  0%   { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-item .thumb-heic-label {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  color: #71717a;
  font-weight: 600;
  text-transform: uppercase;
  gap: 4px;
}

.thumb-item .thumb-heic-label svg {
  width: 24px;
  height: 24px;
  color: #a1a1aa;
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(26, 26, 26, 0.7);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
}

.thumb-item:hover .thumb-remove {
  opacity: 1;
}

/* On touch devices, always show remove button */
@media (hover: none) {
  .thumb-remove {
    opacity: 1;
  }
}

.thumb-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3px 5px;
  background: rgba(26, 26, 26, 0.6);
  color: #fff;
  font-size: 0.625rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Progress Bar --- */
.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.progress-wrapper[hidden] {
  display: none;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #e4e4e7;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #F5C518;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #52525b;
  min-width: 36px;
  text-align: right;
}

/* --- Submit Button --- */
.submit-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #F5C518;
  color: #1a1a1a;
  transition: background-color 0.2s, opacity 0.2s, transform 0.1s;
  letter-spacing: 0.01em;
}

.submit-btn:hover:not(:disabled) {
  background: #FFD700;
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.submit-btn.uploading {
  opacity: 0.7;
  cursor: wait;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  animation: toast-in 0.35s ease;
  max-width: 360px;
  word-break: break-word;
}

.toast.success {
  background: #16a34a;
}

.toast.error {
  background: #dc2626;
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  0%   { opacity: 0; transform: translateX(40px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(40px); }
}

/* --- Results Panel --- */
.results-panel[hidden] {
  display: none;
}

.results-header {
  margin-bottom: 24px;
  text-align: center;
}

.results-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.results-summary {
  font-size: 0.875rem;
  color: #71717a;
}

.result-group {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e4e4e7;
}

.result-group:last-child {
  border-bottom: none;
  margin-bottom: 16px;
  padding-bottom: 0;
}

.result-group-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-previews {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.result-card {
  flex: 0 0 auto;
  width: 160px;
  background: #f4f4f5;
  border-radius: 8px;
  overflow: hidden;
  animation: thumb-in 0.25s ease;
}

.result-card-label {
  padding: 8px 10px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #52525b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.result-card-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #ffffff;
  display: block;
}

.result-card-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #a1a1aa;
  font-size: 0.625rem;
  font-weight: 600;
  gap: 4px;
}

.result-card-placeholder svg {
  width: 28px;
  height: 28px;
}

.result-card-loading {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.result-card-loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid #e4e4e7;
  border-top-color: #F5C518;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.result-card-size {
  padding: 4px 10px;
  font-size: 0.75rem;
  color: #71717a;
}

.result-card-reduction {
  display: inline-block;
  background: #dcfce7;
  color: #16a34a;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.result-card-download {
  display: block;
  width: 100%;
  padding: 8px;
  border: none;
  background: #1a1a1a;
  color: #F5C518;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
}

.result-card-download:hover {
  background: #2a2a2a;
}

.result-group-error {
  padding: 12px;
  background: #fef2f2;
  border-radius: 8px;
  color: #dc2626;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-top: 8px;
}

.results-content {
  margin-bottom: 20px;
}

/* --- Login Overlay --- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 26, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.login-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 48px 36px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: login-in 0.35s ease;
}

@keyframes login-in {
  0%   { opacity: 0; transform: scale(0.92) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.login-logo {
  height: 48px;
  width: auto;
  border-radius: 6px;
  margin-bottom: 16px;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: #71717a;
  margin-bottom: 24px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field input {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1.5px solid #d4d4d8;
  border-radius: 8px;
  background: #ffffff;
  color: #1a1a1a;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  outline: none;
  border-color: #F5C518;
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.2);
}

.login-btn {
  width: 100%;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #F5C518;
  color: #1a1a1a;
  transition: background-color 0.2s, opacity 0.2s;
}

.login-btn:hover:not(:disabled) {
  background: #FFD700;
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.login-error {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: #dc2626;
  font-weight: 500;
}

.login-error[hidden] {
  display: none;
}

/* --- Logout Button --- */
.logout-btn {
  background: none;
  border: none;
  color: #71717a;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
}

.logout-btn:hover {
  color: #F5C518;
  background: rgba(245, 197, 24, 0.1);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 0.8125rem;
  color: #a1a1aa;
  letter-spacing: 0.02em;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
  .header-inner {
    height: 56px;
  }

  .logo {
    height: 32px;
  }

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

  .main {
    padding: 20px 10px 36px;
  }

  .card {
    padding: 28px 20px 24px;
    border-radius: 10px;
  }

  .thumbnail-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
  }

  .drop-zone {
    padding: 24px 12px;
  }

  .toast-container {
    top: 68px;
    right: 10px;
    left: 10px;
  }

  .toast {
    max-width: 100%;
  }

  .result-card {
    width: 140px;
  }

  .result-previews {
    gap: 8px;
  }
}
