/* =====================================
   RESET
===================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}


/* =====================================
   PAGE
===================================== */

html {
  width: 100%;
  min-height: 100%;
}

body {
  width: 100%;
  min-height: 100vh;

  font-family: Arial, Helvetica, sans-serif;

  background: linear-gradient(
    135deg,
    #f8f7ff 0%,
    #f5f5f7 50%,
    #f8f7ff 100%
  );

  color: #1f2937;

  padding: 40px 20px;

  overflow-x: hidden;
}


/* =====================================
   MAIN CONTAINER
===================================== */

.container {
  width: 100%;
  max-width: 900px;

  margin: 0 auto;
}


/* =====================================
   HEADER
===================================== */

.app-header {
  width: 100%;

  text-align: center;

  margin-bottom: 30px;
}

.app-header h1 {
  font-size: 42px;
  font-weight: 700;

  margin-bottom: 10px;

  color: #1f2937;
}

.app-header p {
  font-size: 17px;

  color: #6b7280;

  line-height: 1.6;
}


/* =====================================
   CARD
===================================== */

.card {
  width: 100%;

  background: #ffffff;

  border-radius: 20px;

  padding: 30px;

  margin-bottom: 25px;

  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);

  overflow: hidden;
}


/* =====================================
   SECTION HEADING
===================================== */

.section-heading {
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: 26px;

  margin-bottom: 8px;

  color: #1f2937;
}

.section-heading p {
  font-size: 15px;

  color: #6b7280;

  line-height: 1.5;
}


/* =====================================
   UPLOAD AREA
===================================== */

.upload-area {
  width: 100%;
  min-height: 180px;

  display: flex;

  align-items: center;
  justify-content: center;

  border: 2px dashed #8b5cf6;

  border-radius: 16px;

  padding: 30px 20px;

  cursor: pointer;

  overflow: hidden;

  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.upload-area:hover {
  background: #faf7ff;

  border-color: #6d28d9;
}

.upload-area.drag-active {
  background: #f3e8ff;

  border-color: #6d28d9;

  transform: scale(1.01);
}


/* =====================================
   FILE INPUT
===================================== */

#imageInput {
  display: none;
}


/* =====================================
   UPLOAD LABEL
===================================== */

.upload-label {
  width: 100%;

  display: flex;

  flex-direction: column;

  align-items: center;
  justify-content: center;

  text-align: center;

  cursor: pointer;

  user-select: none;
}

.upload-icon {
  font-size: 42px;

  margin-bottom: 12px;
}

.upload-title {
  font-size: 18px;

  font-weight: 700;

  color: #6d28d9;

  margin-bottom: 8px;
}

.upload-text {
  font-size: 14px;

  color: #6b7280;
}


/* =====================================
   IMAGE PREVIEW CONTAINER
===================================== */

.preview-container {
  display: none;

  width: 100%;

  margin-top: 20px;

  padding: 12px;

  background: #f9fafb;

  border: 1px solid #e5e7eb;

  border-radius: 16px;

  overflow: hidden;

  text-align: center;
}


/* =====================================
   IMAGE PREVIEW
===================================== */

#imagePreview {
  display: block;

  width: auto;

  max-width: 100%;

  height: auto;

  max-height: 450px;

  margin: 0 auto;

  object-fit: contain;

  border-radius: 10px;
}


/* =====================================
   EXTRACT BUTTON
===================================== */

#extractBtn {
  width: 100%;

  margin-top: 20px;

  border: none;

  border-radius: 14px;

  padding: 17px 20px;

  font-size: 17px;

  font-weight: 700;

  color: #ffffff;

  background: linear-gradient(
    135deg,
    #6d28d9,
    #8b5cf6
  );

  cursor: pointer;

  transition:
    transform 0.2s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;
}

#extractBtn:hover:not(:disabled) {
  transform: translateY(-2px);

  box-shadow: 0 8px 20px rgba(109, 40, 217, 0.3);
}

#extractBtn:disabled {
  opacity: 0.5;

  cursor: not-allowed;

  box-shadow: none;

  transform: none;
}


/* =====================================
   STATUS
===================================== */

#status {
  width: 100%;

  text-align: center;

  margin-top: 15px;

  min-height: 22px;

  font-size: 14px;

  color: #6b7280;

  line-height: 1.5;

  overflow-wrap: break-word;
}


/* =====================================
   RESULTS CARD
===================================== */

.results-card {
  width: 100%;
}


/* =====================================
   RESULT HEADER
===================================== */

.result-header {
  width: 100%;

  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 15px;

  margin-bottom: 15px;
}

.result-title-area {
  min-width: 0;
}

.result-header h2 {
  font-size: 26px;

  margin-bottom: 8px;

  color: #1f2937;
}

.result-header p {
  font-size: 15px;

  color: #6b7280;

  line-height: 1.5;
}


/* =====================================
   COPY BUTTON
===================================== */

#copyBtn {
  flex-shrink: 0;

  border: none;

  border-radius: 10px;

  padding: 10px 16px;

  background: #111827;

  color: #ffffff;

  font-size: 14px;

  font-weight: 600;

  cursor: pointer;

  white-space: nowrap;

  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

#copyBtn:hover {
  transform: translateY(-1px);

  opacity: 0.9;
}


/* =====================================
   RESULT TEXTAREA
===================================== */

#result {
  display: block;

  width: 100%;

  min-width: 0;

  min-height: 280px;

  resize: vertical;

  border: 1px solid #e5e7eb;

  border-radius: 14px;

  padding: 20px;

  background: #f9fafb;

  color: #1f2937;

  font-family: "Courier New", monospace;

  font-size: 16px;

  line-height: 1.7;

  outline: none;

  overflow-wrap: break-word;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#result:focus {
  border-color: #8b5cf6;

  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}


/* =====================================
   TABLET / MOBILE
===================================== */

@media (max-width: 700px) {

  body {
    padding: 20px 12px;
  }

  .container {
    max-width: 100%;
  }

  .app-header {
    margin-bottom: 20px;
  }

  .app-header h1 {
    font-size: 32px;
  }

  .app-header p {
    font-size: 15px;
  }

  .card {
    padding: 20px;

    border-radius: 16px;
  }

  .section-heading h2 {
    font-size: 23px;
  }

  .upload-area {
    min-height: 160px;

    padding: 25px 15px;
  }

  .preview-container {
    padding: 8px;
  }

  #imagePreview {
    max-height: 350px;
  }

  .result-header {
    flex-direction: column;

    align-items: stretch;
  }

  #copyBtn {
    width: 100%;
  }

  #result {
    min-height: 220px;

    padding: 16px;

    font-size: 14px;
  }
}


/* =====================================
   SMALL MOBILE
===================================== */

@media (max-width: 400px) {

  body {
    padding: 15px 10px;
  }

  .app-header h1 {
    font-size: 28px;
  }

  .card {
    padding: 16px;
  }

  .upload-title {
    font-size: 16px;
  }

  .upload-icon {
    font-size: 36px;
  }

  #imagePreview {
    max-height: 280px;
  }
}
/* =====================================
   RESULT ACTION BUTTONS
===================================== */

.result-actions {
  display: flex;

  align-items: center;

  gap: 10px;

  flex-shrink: 0;
}


/* =====================================
   DOWNLOAD BUTTON
===================================== */

#downloadBtn {
  border: none;

  border-radius: 10px;

  padding: 10px 16px;

  background: #6d28d9;

  color: #ffffff;

  font-size: 14px;

  font-weight: 600;

  cursor: pointer;

  white-space: nowrap;

  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

#downloadBtn:hover {
  transform:
    translateY(-1px);

  opacity: 0.9;
}


/* =====================================
   CLEAR BUTTON
===================================== */

#clearBtn {
  border: none;

  border-radius: 10px;

  padding: 10px 16px;

  background: #e5e7eb;

  color: #1f2937;

  font-size: 14px;

  font-weight: 600;

  cursor: pointer;

  white-space: nowrap;

  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

#clearBtn:hover {
  transform:
    translateY(-1px);

  background: #d1d5db;
}


/* =====================================
   MOBILE RESULT ACTIONS
===================================== */

@media (max-width: 700px) {

  .result-actions {
    width: 100%;

    flex-direction: column;
  }

  .result-actions button {
    width: 100%;
  }

}