@import "../../../../assets/scss/variables";

// Local theme tokens for things the project variables don't cover.
:root {
  --vf-border: #d0e4ff;        // field / file-card border
  --vf-dz-border: #6f9fd0;     // dashed dropzone border
  --vf-disabled: #cccccc;      // disabled button (Figma #CCCCCC)
}

:root[data-theme="dark"] {
  --vf-border: #2F363E;
  --vf-dz-border: #6b7683;
  --vf-disabled: #5b636d;
}

// One height for every control on a row: CustomTextField (user-form-field) is 30px,
// so selects, the dropzone and the buttons next to fields use the same.
$vf-control-h: 30px;
// the underline colour CustomTextField uses; selects and the textarea copy it
$vf-underline: #707070;

// Must match the container's className in VevaiosiSingle.tsx
// (was .vevaiosi-single-container, which never matched, so this rule never applied).
.vevaiosi-view-container {
  // Section background: your form-background variable (#F3F8FC light / #40474F dark)
  .light {
    background-color: $form-background !important;
  }
}

// status pill above the title of a read-only record; modifier = statusUiType()
.vevaiosi-status {
  display: inline-block;
  margin-bottom: 1.2rem;
  padding: .4rem 1.4rem;
  border-radius: 20px;
  color: #fff;
  font-size: 1rem;
  font-weight: $bold;
  text-transform: uppercase;
  background: #6c757d;                 // default / unknown status

  &--success { background: $success-color; }
  &--pending { background: #e0a020; }
  &--error   { background: $error-color; }
}

.vevaiosi-page-desc {
  color: $text-color;
  font-size: $input-size;
  margin: .5rem 0 0;
}

// Shown by VevaiosiSingle when the initial fetch fails.
.vevaiosi-load-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.6rem;
  padding: 3rem 0;
  color: $text-color;
  font-size: $input-size;

  p { margin: 0; }
}

.vevaiosi-form {
  .vf-section-title {
    color: $title-color;
    font-size: $title;
    font-weight: $bold;
    margin-bottom: 2.5rem;
  }

  .vf-field { display: flex; flex-direction: column; gap: .4rem; }

  /* ------------- shared form components, brought to one baseline ------------- */
  // CustomRadioSelect (form-options) is 45px with a black underline, a 33px indent and bigger text,
  // so it sat lower than the CustomTextFields beside it. Match the text field instead.
  .custom-radio-select.form-options {
    min-width: 0;                        // the component's 350px overflowed the narrower columns

    .select-head {
      height: $vf-control-h;
      padding-left: 0;
      border-bottom: 1px solid $vf-underline;

      li, .select-placeholder {
        font-size: $input-size;
        font-weight: $extra-light;
        color: $text-color;
        letter-spacing: .8px;
      }
      .down-arrow { padding-right: 4px; }

      // read-only: no underline, like a disabled CustomTextField
      &.disabled { border-bottom-color: transparent; }
    }

    .options { top: $vf-control-h; }
  }

  // CustomTextArea: no left indent and the same underline colour as the text fields
  .text-area.user-form-field {
    padding-left: 0;
    border-bottom-color: $vf-underline;
  }
  .vf-hint { color: $text-color; font-size: $index-size; font-weight: $regular; opacity: .8; }
  .vf-row { margin-bottom: 1rem; }
  .vf-empty { color: $text-color; font-size: $input-size; text-align: center; padding: 3rem 0; opacity: .7; }

  .vf-divider {
    border: 0;
    border-top: 1px solid $text-color;
    margin: 2rem 0;
    opacity: .5;
  }

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

  /* ------------------------------ buttons ----------------------------- */
  .vf-subhead {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 2.5rem;
    color: $title-color;
    font-size: $input-size;
  }

  .vf-btn {
    height: 34px;
    padding: 0 1.4rem;
    font-size: $index-size;
    font-weight: $semi-bold;
    cursor: pointer;
    border: 1px solid $title-color;
    &:disabled { opacity: .45; cursor: not-allowed; }
  }
  .vf-btn--dark { background: $blue-to-gray; border-color: $blue-to-gray; color: #fff; }
  .vf-btn--ghost { background: transparent; color: $title-color; }

  // delete buttons next to inputs: DeleteRowButton puts an empty label above it,
  // so it starts where the inputs start and only needs the same height
  .vf-del-btn { height: $vf-control-h; }

  .vf-btn--lg {
    width: 160px;
    height: $vf-control-h;
    padding: 0;
    border: 0;
    border-radius: 2px;
    font-family: $font-family;
    font-size: 14px;
    font-weight: $bold;
    line-height: 1;
    letter-spacing: 0;
  }
  .vf-btn--green {
    background: $success-color;
    color: #fff;
    &:disabled { background: var(--vf-disabled); opacity: 1; }
  }

  // inline text button (e.g. "Αφαίρεση επιλογής" under the dropzone)
  .vf-link-btn {
    background: none;
    border: 0;
    padding: 0;
    margin-left: .8rem;
    color: $title-color;
    font-size: inherit;
    font-weight: $semi-bold;
    text-decoration: underline;
    cursor: pointer;
    &:hover { opacity: .7; }
  }

  .vevaiosi-file-add-button button{
    height: 50px;
  }

  /* ----------------- bottom action buttons (FormButton*) ---------------- */
  .vf-actions {
    // navy buttons; ΑΚΥΡΩΣΗ stays red
    .form-button:not(:disabled):not(.cancel) {
      background-color: $blue-to-gray;
      color: #fff;
      font-weight: $bold;

      hr { background-color: #fff; }
      img { filter: $svg-white; }
    }

    // ΠΙΣΩ / ΑΚΥΡΩΣΗ: icon | text. FormButton only draws its <hr/> when the icon comes second,
    // so draw the divider with a pseudo-element and move the icon in front of it.
    .form-button.back,
    .form-button.cancel {
      > img { order: -1; }
      &::before {
        content: '';
        width: 1px;
        height: 27px;                      // same size as the real <hr/>
        background-color: #fff;
      }
    }
    .form-button.cancel::before { background-color: var(--black-hr); }

    // ΑΠΟΘΗΚΕΥΣΗ: text | icon. FormButtonSave puts the icon first and its icon is not an <img>,
    // so FormButton draws no <hr/>. Flex order: text (0), divider (1), icon (2).
    .form-button.save {
      > :first-child { order: 2; }         // the Save icon goes last, whatever element it renders
      &::before {
        content: '';
        order: 1;
        width: 1px;
        height: 27px;
        background-color: #fff;
      }
    }
  }

  /* ------------------------ ΕΛΕΓΧΟΣ ΠΛΗΡΩΜΩΝ (summary) ------------------------ */
  // one button, two states: idle (card icon) and waiting for ΚΕΔ (spinning icon, disabled)
  .vf-pay-check {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    width: 50%;                          // half of its cell
    min-height: 40px;
    padding: 0 1.6rem;
    border: 0;
    border-radius: 2px;
    background: $blue-to-gray;
    color: #fff;
    font-size: $index-size;
    font-weight: $bold;
    cursor: pointer;

    &:hover:not(:disabled) { opacity: .85; }
    // waiting keeps the navy look (it is busy, not unavailable)
    &:disabled { cursor: progress; }
  }

  .vf-pay-check--waiting .vf-pay-spinner { animation: vf-spin 1s linear infinite; }

  /* --------------------------- Σχόλια / Αιτιολογία --------------------------- */
  .vf-comments {
    margin-top: 4rem;
    .vf-block-title { margin-bottom: 2rem; }
  }
  .vf-comments-text {
    margin: 0;
    color: $text-color;
    font-size: $input-size;
    white-space: pre-line;               // keep the line breaks the user typed
    overflow-wrap: anywhere;
  }

  /* --------------------------- Ταυτότητες Οφειλής ---------------------------- */
  .vf-debts { margin-top: 4rem; }

  // title with the explanation next to it, as in the design
  .vf-debts-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .4rem 1.2rem;
    margin-bottom: 2rem;
  }
  // section titles under the summary card (Σχόλια / Αιτιολογία, Ταυτότητες Οφειλής)
  .vf-block-title {
    margin: 0;
    color: $title-color;
    font-size: 2.6rem;
    font-weight: $bold;
  }
  .vf-debts-desc { color: $text-color; font-size: $input-size; }

  // in a list row the button sizes to its text, not to half a form cell
  .vf-debts .vf-pay-check {
    width: auto;
    min-width: 190px;
    margin: 0 auto;
    white-space: nowrap;
  }

  /* ------------------------ Έλεγχος Πληρωμών sidebar ------------------------ */
  // Rendered by SidebarOverlay (fixed, on the right) but still inside .vevaiosi-form in the DOM,
  // so these and the .vf-field rules apply to it.
  .vf-pay-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2.4rem;
    padding-bottom: 4rem;
    text-align: left;
  }

  .vf-pay-sidebar-title {
    margin: 0;
    color: $title-color;
    font-size: 30px;
    font-weight: 300;
    line-height: 35px;
    letter-spacing: .6px;
  }

  .vf-pay-sidebar-debt {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    span { color: $text-color; font-size: $input-size; }
    b { color: $title-color; font-size: $input-size; overflow-wrap: anywhere; }
  }

  .vf-pay-sidebar-fields {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
  }

  .vf-pay-sidebar-updated {
    display: flex;
    flex-direction: column;
    color: $text-color;
    font-size: $index-size;
    line-height: 1.5;
  }

  /* ------------------------------ files ------------------------------- */
  .vf-dropzone {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 1.6rem;
    cursor: pointer;
    background: $rolebox-background;
    border: 1px dashed var(--vf-dz-border);
    color: $text-color;
    font-size: $input-size;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    &.has-file { color: $title-color; }
  }

  // title input + dropzone share the free space; the button column is exactly 160px wide
  .vf-file-row {
    @media (min-width: 768px) {
      flex-wrap: nowrap;
      > .col-md-5 { flex: 1 1 0; width: auto; min-width: 0; }
      > .col-md-2 { flex: 0 0 auto; width: auto; }
    }
  }

  .vf-files-title {
    color: $title-color;
    font-size: $info-size;
    font-weight: $bold;
    margin: 2rem 0 1.2rem;
  }

  .vf-file-item {
    display: flex;
    align-items: center;
    gap: 1.6rem;
    padding: 1.4rem 2rem;
    margin-bottom: 1.2rem;
    background: $white-box-background;
    border: 1px solid var(--vf-border);
  }
  // Modifiers must match ICON_TYPES in FilesSection.tsx; anything else gets --other.
  .vf-file-icon {
    position: relative;
    flex: 0 0 auto;
    width: 28px;
    height: 34px;
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 5px;
    color: #fff;
    font-size: 8px;
    font-weight: $bold;
    letter-spacing: -.2px;               // 4-letter labels (XLSX, DOCX) fit the 28px box
    &--pdf   { background: #e2403c; }
    &--zip   { background: $blue-to-gray; }
    &--xlsx  { background: #1d7a46; }
    &--docx  { background: #2b5797; }
    &--jpg   { background: #c27c0e; }
    &--other { background: #6c757d; }
    &::before, &::after {
      content: "";
      position: absolute;
    }

    &::after {
      width: 0;
      height: 0;
      border-bottom: 10px solid #e5dfdf;
      border-right: 10px solid transparent;
      top: 0;
      right: 0;
    }
    &::before {
      width: 0;
      height: 0;
      border-top: 10px solid var(--white-box-background);
      border-left: 10px solid transparent;
      top: 0;
      right: 0;
      background-color: white;
    }
  }
  .vf-file-info {
    flex: 1;
    min-width: 0;
    b { display: block; color: $title-color; font-size: $input-size; }
    span { display: block; color: $text-color; font-size: $info-size; }
  }
  // row being deleted on the backend
  .vf-file-item.is-removing { opacity: .5; }

  .vf-file-actions { display: flex; align-items: center; gap: 3rem; }
  .vf-icon-btn {
    background: none;
    border: 0;
    padding: 4px;
    cursor: pointer;
    color: $title-color;
    &:hover { opacity: .7; }
    &:disabled { opacity: .4; cursor: not-allowed; }
  }
}

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