/* ==========================================================
   GLOBAL RESET & BASE STYLES
   ========================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #e8f5e9;
  --accent: #66bb6a;
  --danger: #c62828;
  --danger-bg: #fdecea;
  --warning-bg: #fff8e1;
  --warning-text: #8a6d00;
  --text-main: #212121;
  --text-muted: #616161;
  --bg: #f4f7f5;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  padding: 20px;
}

.app-container {
  max-width: 720px;
  margin: 0 auto;
}

/* ==========================================================
   HEADER
   ========================================================== */
.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 2rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ==========================================================
   CARD CONTAINER
   ========================================================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--primary-dark);
}

/* ==========================================================
   UPLOAD SECTION
   ========================================================== */
.upload-section {
  margin-bottom: 20px;
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 36px 20px;
  cursor: pointer;
  background: var(--primary-light);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.upload-label:hover,
.upload-label.dragover {
  background: #dcf0dd;
  border-color: var(--primary-dark);
}

.upload-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==========================================================
   IMAGE PREVIEW
   ========================================================== */
.preview-section {
  margin-bottom: 20px;
  text-align: center;
}

#imagePreview {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
}

/* ==========================================================
   BUTTONS
   ========================================================== */
.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn {
  flex: 1;
  min-width: 140px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eeeeee;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #e0e0e0;
}

/* ==========================================================
   LOADING INDICATOR
   ========================================================== */
.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-light);
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================
   ERROR BOX
   ========================================================== */
.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(198, 40, 40, 0.25);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

/* ==========================================================
   RESULT CARD
   ========================================================== */
.result-card {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(46, 125, 50, 0.15);
}

.result-main {
  margin-bottom: 16px;
}

.result-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.predicted-class {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.confidence-block {
  margin-bottom: 12px;
}

.confidence-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.progress-track {
  width: 100%;
  height: 14px;
  background: #dcdcdc;
  border-radius: 20px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--primary-dark));
  transition: width 0.6s ease;
}

/* Unknown / unsupported image message */
.unknown-message {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid rgba(138, 109, 0, 0.25);
  padding: 12px 16px;
  border-radius: 10px;
  margin-top: 14px;
  font-size: 0.92rem;
}

/* Breakdown of all class scores */
.all-scores {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

/* ==========================================================
   LIMITATION NOTICE
   ========================================================== */
.limitation-notice {
  font-size: 0.82rem;
  color: var(--warning-text);
  background: var(--warning-bg);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
  border: 1px solid rgba(138, 109, 0, 0.2);
}

/* ==========================================================
   PAGE FOOTER
   ========================================================== */
.page-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 480px) {
  .app-header h1 {
    font-size: 1.6rem;
  }

  .card {
    padding: 18px;
  }

  .btn {
    min-width: 100%;
  }
}
