/* ============================================================
   DIGITAL DRAUGHT
   PRIVATE PINTEREST UPLOAD DASHBOARD
   ============================================================ */

/* ============================================================
   RESET
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #f5f5f5;
  color: #171717;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

/* ============================================================
   APP
   ============================================================ */

.app {
  min-height: 100vh;
}

/* ============================================================
   VIEWS
   ============================================================ */

.view {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ============================================================
   LOGIN
   ============================================================ */

#loginView {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: radial-gradient(
    circle at top,
    #ffffff 0,
    #f7f7f7 45%,
    #eeeeee 100%
  );
}

/* ============================================================
   AUTH CARD
   ============================================================ */

.auth-card {
  width: 100%;
  max-width: 430px;
  padding: 40px;
  background: #ffffff;
  border: 1px solid #e4e4e4;
  border-radius: 20px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ============================================================
   BRAND
   ============================================================ */

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.auth-card .brand {
  margin-bottom: 34px;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #171717;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 4px 0 0;
  color: #737373;
  font-size: 13px;
  line-height: 1.2;
}

/* ============================================================
   FIELDS
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field + .field {
  margin-top: 18px;
}

.field label {
  color: #303030;
  font-size: 13px;
  font-weight: 650;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  outline: none;
  background: #ffffff;
  color: #171717;
  font-size: 14px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.field input::placeholder {
  color: #a0a0a0;
}

.field input:hover {
  border-color: #bdbdbd;
}

.field input:focus {
  border-color: #171717;
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.08);
}

/* ============================================================
   INPUT WITH SUFFIX
   ============================================================ */

.input-with-suffix {
  position: relative;
}

.input-with-suffix input {
  padding-right: 78px;
}

.input-with-suffix span {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  color: #888888;
  font-size: 12px;
  pointer-events: none;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 10px;
  padding: 0 18px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 100ms ease,
    box-shadow 150ms ease,
    opacity 150ms ease;
}

.primary-button {
  background: #171717;
  color: #ffffff;
  border-color: #171717;
}

.primary-button:hover {
  background: #303030;
  border-color: #303030;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.14);
}

.primary-button:disabled {
  opacity: 0.55;
}

.secondary-button {
  background: #ffffff;
  color: #303030;
  border-color: #d8d8d8;
}

.secondary-button:hover {
  background: #f7f7f7;
  border-color: #c7c7c7;
}

.auth-card .primary-button {
  width: 100%;
  margin-top: 24px;
}

/* ============================================================
   MESSAGE
   ============================================================ */

.message {
  min-height: 20px;
  margin: 12px 0 0;
  color: #777777;
  font-size: 13px;
  line-height: 1.5;
}

.message.error {
  color: #a52222;
}

.message.success {
  color: #23743a;
}

.message.info {
  color: #666666;
}

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px 32px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
}

.account {
  display: flex;
  align-items: center;
  gap: 14px;
}

#userEmail {
  max-width: 300px;
  overflow: hidden;
  color: #666666;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.panel {
  background: #ffffff;
  border: 1px solid #e2e2e2;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.035);
}

.panel + .panel {
  margin-top: 22px;
}

.panel-header {
  padding: 28px 30px 0;
}

.panel-header h2 {
  margin: 0;
  color: #171717;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.panel-header p {
  max-width: 700px;
  margin: 8px 0 0;
  color: #777777;
  font-size: 13px;
  line-height: 1.6;
}

/* ============================================================
   UPLOAD FORM
   ============================================================ */

#uploadForm {
  padding: 28px 30px 30px;
}

/* ============================================================
   FORM GRID
   ============================================================ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.form-grid .field {
  margin: 0;
}

.field-full {
  grid-column: 1 / -1;
}

/* ============================================================
   UPLOAD ZONE
   ============================================================ */

.upload-zone {
  position: relative;
  margin-top: 28px;
}

.drop-label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 250px;
  padding: 30px;
  border: 1.5px dashed #c8c8c8;
  border-radius: 16px;
  background: #fafafa;
  color: #444444;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.drop-label:hover {
  border-color: #999999;
  background: #f7f7f7;
}

#uploadZone.dragover .drop-label {
  border-color: #171717;
  background: #f2f2f2;
  box-shadow: 0 0 0 4px rgba(23, 23, 23, 0.05);
}

.upload-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 15px;
  border: 1px solid #dddddd;
  border-radius: 14px;
  background: #ffffff;
  color: #171717;
  font-size: 24px;
  font-weight: 400;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.drop-label strong {
  color: #222222;
  font-size: 15px;
  font-weight: 750;
}

.drop-label > span:not(.upload-icon) {
  margin-top: 5px;
  color: #777777;
  font-size: 13px;
}

.drop-label small {
  margin-top: 5px;
  color: #999999;
  font-size: 11px;
}

/* ============================================================
   FILE SUMMARY
   ============================================================ */

.file-summary {
  margin-top: 18px;
  padding: 11px 14px;
  border: 1px solid #e4e4e4;
  border-radius: 10px;
  background: #fafafa;
  color: #555555;
  font-size: 12px;
  font-weight: 600;
}

/* ============================================================
   FILE LIST
   ============================================================ */

.file-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.file-item {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e3e3e3;
  border-radius: 12px;
  background: #ffffff;
}

.file-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f1f1f1;
}

.file-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #999999;
  font-size: 12px;
}

.file-info {
  padding: 10px;
}

.file-name {
  overflow: hidden;
  color: #333333;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  margin-top: 3px;
  color: #999999;
  font-size: 10px;
}

/* ============================================================
   ACTIONS
   ============================================================ */

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid #eeeeee;
}

.actions .primary-button {
  min-width: 220px;
}

/* ============================================================
   RESULT PANEL
   ============================================================ */

.result-panel {
  padding-bottom: 28px;
}

.result-panel .panel-header {
  padding-bottom: 0;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 30px 0;
}

#csvDownload {
  min-width: 220px;
}

/* ============================================================
   LOADING STATE
   ============================================================ */

.primary-button.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.primary-button.loading::after {
  position: absolute;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  content: "";
  animation: button-spinner 700ms linear infinite;
}

@keyframes button-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 800px) {
  .topbar {
    padding: 14px 20px;
  }

  .dashboard {
    width: min(100% - 28px, 700px);
    padding-top: 24px;
  }

  .file-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  #loginView {
    padding: 20px 14px;
  }

  .auth-card {
    padding: 28px 22px;
    border-radius: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px;
  }

  .account {
    width: 100%;
    justify-content: space-between;
  }

  #userEmail {
    max-width: calc(100% - 90px);
  }

  .dashboard {
    width: calc(100% - 24px);
    padding: 18px 0 40px;
  }

  .panel {
    border-radius: 15px;
  }

  .panel-header {
    padding: 22px 18px 0;
  }

  .panel-header h2 {
    font-size: 18px;
  }

  #uploadForm {
    padding: 22px 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .field-full {
    grid-column: auto;
  }

  .upload-zone {
    margin-top: 22px;
  }

  .drop-label {
    min-height: 210px;
    padding: 24px 16px;
  }

  .file-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .actions .primary-button,
  .actions .secondary-button {
    width: 100%;
  }

  .result-actions {
    padding: 20px 18px 0;
  }

  #csvDownload {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .brand h1 {
    font-size: 16px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .file-list {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
