/*
 * WC Warranty Return Form Fix — Frontend Styles
 * Kolorystyka dopasowana do Peco (zielona, ekologiczna)
 * Wersja: 1.2.0
 */

/* ============================================================
   ZMIENNE / TOKENY
   ============================================================ */
:root {
  --wcwrfp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  --wcwrfp-radius: 6px;
  --wcwrfp-radius-sm: 4px;
  --wcwrfp-radius-lg: 10px;

  --wcwrfp-color-bg: #ffffff;
  --wcwrfp-color-surface: #f5f7f5;
  --wcwrfp-color-border: #d4ddd4;
  --wcwrfp-color-border-focus: #3a7d3a;
  --wcwrfp-color-text: #1c2b1c;
  --wcwrfp-color-text-muted: #5a6e5a;
  --wcwrfp-color-text-faint: #8fa68f;

  --wcwrfp-color-primary: #3a7d3a;
  --wcwrfp-color-primary-hover: #2d6a2d;
  --wcwrfp-color-primary-active: #215421;

  --wcwrfp-color-success: #2d6a2d;
  --wcwrfp-color-success-bg: #edf5ed;
  --wcwrfp-color-success-border: #b5d4b5;

  --wcwrfp-color-error: #b83232;
  --wcwrfp-color-error-bg: #fdf2f2;
  --wcwrfp-color-error-border: #f0bbbb;

  --wcwrfp-color-warning-bg: #fdf8ef;
  --wcwrfp-color-warning-border: #e8d49a;
  --wcwrfp-color-warning-text: #7a5c1e;

  --wcwrfp-color-info-bg: #edf5ed;
  --wcwrfp-color-info-border: #b5d4b5;
  --wcwrfp-color-info-text: #2d5a2d;

  --wcwrfp-color-disabled-bg: #f0f3f0;
  --wcwrfp-color-disabled-text: #8fa68f;

  --wcwrfp-color-badge-done-bg: #edf5ed;
  --wcwrfp-color-badge-done-text: #215421;
  --wcwrfp-color-badge-done-border: #b5d4b5;

  --wcwrfp-color-badge-expired-bg: #fdf2f2;
  --wcwrfp-color-badge-expired-text: #8b2020;
  --wcwrfp-color-badge-expired-border: #f0bbbb;

  --wcwrfp-shadow-sm: 0 1px 3px rgba(30, 60, 30, 0.07), 0 1px 2px rgba(30, 60, 30, 0.04);
  --wcwrfp-shadow-md: 0 4px 12px rgba(30, 60, 30, 0.10), 0 2px 4px rgba(30, 60, 30, 0.05);
  --wcwrfp-transition: 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   WRAPPER OGÓLNY
   ============================================================ */
.wcwrfp-verify-form,
.wcwrfp-submit-form {
  font-family: var(--wcwrfp-font);
  color: var(--wcwrfp-color-text);
  max-width: 680px;
  margin: 0 auto;
}

/* ============================================================
   KOMUNIKATY — NOTICES
   ============================================================ */
.woocommerce-error[role="alert"],
.woocommerce-message[role="status"],
.woocommerce-info[role="status"] {
  display: flex !important;
  align-items: flex-start !important;
  gap: 10px !important;
  padding: 13px 16px !important;
  border-radius: var(--wcwrfp-radius) !important;
  font-size: 0.9rem !important;
  line-height: 1.5 !important;
  margin-bottom: 20px !important;
  border-width: 1px !important;
  border-style: solid !important;
  list-style: none !important;
}

/* --- ERROR --- */
.woocommerce-error[role="alert"] {
  background: var(--wcwrfp-color-error-bg) !important;
  border-color: var(--wcwrfp-color-error-border) !important;
  color: var(--wcwrfp-color-error) !important;
}

.woocommerce-error[role="alert"]::before {
  content: "✕" !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 20px !important;
  width: 20px !important;
  height: 20px !important;
  background: var(--wcwrfp-color-error) !important;
  color: #fff !important;
  border-radius: 50% !important;
  font-size: 0.65rem !important;
  font-weight: 700 !important;
  font-family: inherit !important;
  font-style: normal !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
  position: static !important;
  float: none !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.woocommerce-error[role="alert"]::after {
  content: none !important;
  display: none !important;
}

/* --- SUCCESS / MESSAGE --- */
.woocommerce-message[role="status"] {
  background: var(--wcwrfp-color-success-bg) !important;
  border-color: var(--wcwrfp-color-success-border) !important;
  color: var(--wcwrfp-color-success) !important;
}

.woocommerce-message[role="status"]::before {
  content: "✓" !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 20px !important;
  width: 20px !important;
  height: 20px !important;
  background: var(--wcwrfp-color-success) !important;
  color: #fff !important;
  border-radius: 50% !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  font-family: inherit !important;
  font-style: normal !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
  position: static !important;
  float: none !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.woocommerce-message[role="status"]::after {
  content: none !important;
  display: none !important;
}

/* --- INFO --- */
.woocommerce-info[role="status"] {
  background: var(--wcwrfp-color-info-bg) !important;
  border-color: var(--wcwrfp-color-info-border) !important;
  color: var(--wcwrfp-color-info-text) !important;
}

.woocommerce-info[role="status"]::before {
  content: "i" !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 20px !important;
  width: 20px !important;
  height: 20px !important;
  background: var(--wcwrfp-color-primary) !important;
  color: #fff !important;
  border-radius: 50% !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  font-style: italic !important;
  font-family: inherit !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
  position: static !important;
  float: none !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.woocommerce-info[role="status"]::after {
  content: none !important;
  display: none !important;
}

/* ============================================================
   TIMER BOX — okno zwrotu
   ============================================================ */
.wcwrfp-timer-box,
.woocommerce-info.wcwrfp-timer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: var(--wcwrfp-color-warning-bg);
  border: 1px solid var(--wcwrfp-color-warning-border);
  border-radius: var(--wcwrfp-radius);
  color: var(--wcwrfp-color-warning-text);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 24px;
  box-shadow: var(--wcwrfp-shadow-sm);
}

/* ============================================================
   FORMULARZ WERYFIKACJI
   ============================================================ */
.wcwrfp-verify-form {
  background: var(--wcwrfp-color-bg);
  border: 1px solid var(--wcwrfp-color-border);
  border-radius: var(--wcwrfp-radius-lg);
  padding: 32px 36px;
  box-shadow: var(--wcwrfp-shadow-md);
}

.wcwrfp-verify-form p {
  margin: 0 0 20px;
}

.wcwrfp-verify-form p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   INFO ZAMÓWIENIA (pierwszy paragraf w submit)
   ============================================================ */
.wcwrfp-submit-form > p:first-of-type {
  padding: 13px 18px;
  background: var(--wcwrfp-color-surface);
  border: 1px solid var(--wcwrfp-color-border);
  border-left: 3px solid var(--wcwrfp-color-primary);
  border-radius: var(--wcwrfp-radius);
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--wcwrfp-color-text-muted);
}

/* ============================================================
   LABELS
   ============================================================ */
.wcwrfp-verify-form label,
.wcwrfp-submit-form > p > label:not([for=""]) {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--wcwrfp-color-text);
  margin-bottom: 6px;
}

/* ============================================================
   INPUTY / TEXTAREA
   ============================================================ */
.wcwrfp-verify-form input[type="text"],
.wcwrfp-verify-form input[type="email"],
.wcwrfp-verify-form input[type="number"],
.wcwrfp-verify-form textarea,
.wcwrfp-submit-form input[type="text"],
.wcwrfp-submit-form input[type="email"],
.wcwrfp-submit-form input[type="number"],
.wcwrfp-submit-form textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--wcwrfp-color-text);
  background: var(--wcwrfp-color-bg);
  border: 1.5px solid var(--wcwrfp-color-border);
  border-radius: var(--wcwrfp-radius);
  outline: none;
  transition: border-color var(--wcwrfp-transition), box-shadow var(--wcwrfp-transition);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.wcwrfp-verify-form input[type="text"]:focus,
.wcwrfp-verify-form input[type="email"]:focus,
.wcwrfp-verify-form input[type="number"]:focus,
.wcwrfp-verify-form textarea:focus,
.wcwrfp-submit-form input[type="text"]:focus,
.wcwrfp-submit-form input[type="email"]:focus,
.wcwrfp-submit-form input[type="number"]:focus,
.wcwrfp-submit-form textarea:focus {
  border-color: var(--wcwrfp-color-border-focus);
  box-shadow: 0 0 0 3px rgba(58, 125, 58, 0.13);
}

.wcwrfp-verify-form input:disabled,
.wcwrfp-verify-form textarea:disabled,
.wcwrfp-submit-form input:disabled,
.wcwrfp-submit-form textarea:disabled {
  background: var(--wcwrfp-color-disabled-bg);
  color: var(--wcwrfp-color-disabled-text);
  cursor: not-allowed;
  border-color: var(--wcwrfp-color-border);
}

.wcwrfp-submit-form textarea {
  resize: vertical;
  min-height: 100px;
}

.wcwrfp-submit-form input[type="number"] {
  width: 72px;
  padding: 8px 10px;
  text-align: center;
  flex-shrink: 0;
}

/* ============================================================
   PRODUKTY — KARTY ITEMÓW
   ============================================================ */
.wcwrfp-submit-form p:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 14px 16px;
  background: var(--wcwrfp-color-bg);
  border: 1.5px solid var(--wcwrfp-color-border);
  border-radius: var(--wcwrfp-radius);
  transition: border-color var(--wcwrfp-transition), box-shadow var(--wcwrfp-transition);
  margin-bottom: 10px;
}

.wcwrfp-submit-form p:has(input[type="checkbox"]):has(input[type="checkbox"]:not(:disabled)):hover {
  border-color: var(--wcwrfp-color-primary);
  box-shadow: 0 0 0 3px rgba(58, 125, 58, 0.09);
}

.wcwrfp-submit-form p:has(input[type="checkbox"]:disabled) {
  background: var(--wcwrfp-color-surface);
  opacity: 0.80;
}

/* Label produktu */
.wcwrfp-submit-form p > label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--wcwrfp-color-text);
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.wcwrfp-submit-form p > label:has(input:disabled) {
  cursor: default;
  color: var(--wcwrfp-color-text-muted);
}

/* Custom checkbox — zielony */
.wcwrfp-submit-form input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--wcwrfp-color-border);
  border-radius: var(--wcwrfp-radius-sm);
  background: var(--wcwrfp-color-bg);
  cursor: pointer;
  position: relative;
  transition: background var(--wcwrfp-transition), border-color var(--wcwrfp-transition);
  flex-shrink: 0;
}

.wcwrfp-submit-form input[type="checkbox"]:checked {
  background: var(--wcwrfp-color-primary);
  border-color: var(--wcwrfp-color-primary);
}

.wcwrfp-submit-form input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
}

.wcwrfp-submit-form input[type="checkbox"]:disabled {
  background: var(--wcwrfp-color-disabled-bg);
  border-color: var(--wcwrfp-color-border);
  cursor: not-allowed;
}

/* Badgey statusów */
.wcwrfp-submit-form p > small {
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 3px 9px;
  border-radius: var(--wcwrfp-radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.wcwrfp-submit-form p:has(input[type="checkbox"]:not(:disabled)) > small {
  color: var(--wcwrfp-color-text-muted);
  background: var(--wcwrfp-color-surface);
  border: 1px solid var(--wcwrfp-color-border);
}

.wcwrfp-submit-form p:has(input[type="checkbox"]:disabled):has(small) > small:first-of-type {
  background: var(--wcwrfp-color-badge-done-bg);
  color: var(--wcwrfp-color-badge-done-text);
  border: 1px solid var(--wcwrfp-color-badge-done-border);
  font-weight: 500;
}

/* ============================================================
   SEKCJA POWÓD / NOTATKI / TRACKING
   ============================================================ */
.wcwrfp-submit-form > p:has(> label[for="wcwrfp_reason"]),
.wcwrfp-submit-form > p:has(> label[for="wcwrfp_notes"]),
.wcwrfp-submit-form > p:has(> label[for="tracking_provider"]),
.wcwrfp-submit-form > p:has(> label[for="tracking_code"]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

/* ============================================================
   SELECT
   ============================================================ */
.wcwrfp-submit-form select#wcwrfp_reason {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  color: var(--wcwrfp-color-text);
  background: var(--wcwrfp-color-bg);
  border: 1.5px solid var(--wcwrfp-color-border);
  border-radius: var(--wcwrfp-radius);
  outline: none;
  cursor: pointer;
  transition: border-color var(--wcwrfp-transition), box-shadow var(--wcwrfp-transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6e5a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  box-sizing: border-box;
}

.wcwrfp-submit-form select#wcwrfp_reason:focus {
  border-color: var(--wcwrfp-color-border-focus);
  box-shadow: 0 0 0 3px rgba(58, 125, 58, 0.13);
}

/* ============================================================
   PRZYCISK SUBMIT
   ============================================================ */
.wcwrfp-verify-form button[type="submit"],
.wcwrfp-submit-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 30px;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  background: var(--wcwrfp-color-primary);
  border: none;
  border-radius: var(--wcwrfp-radius);
  cursor: pointer;
  transition: background var(--wcwrfp-transition), transform var(--wcwrfp-transition), box-shadow var(--wcwrfp-transition);
  box-shadow: 0 2px 6px rgba(45, 106, 45, 0.35);
  min-width: 160px;
  -webkit-appearance: none;
  appearance: none;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.wcwrfp-verify-form button[type="submit"]:hover,
.wcwrfp-submit-form button[type="submit"]:hover {
  background: var(--wcwrfp-color-primary-hover);
  box-shadow: 0 4px 14px rgba(45, 106, 45, 0.4);
  transform: translateY(-1px);
}

.wcwrfp-verify-form button[type="submit"]:active,
.wcwrfp-submit-form button[type="submit"]:active {
  background: var(--wcwrfp-color-primary-active);
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(45, 106, 45, 0.25);
}

.wcwrfp-verify-form button[type="submit"]:disabled,
.wcwrfp-submit-form button[type="submit"]:disabled {
  background: var(--wcwrfp-color-disabled-bg);
  color: var(--wcwrfp-color-disabled-text);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.wcwrfp-verify-form p:has(button),
.wcwrfp-submit-form p:has(button[type="submit"]) {
  margin-top: 28px;
}

/* ============================================================
   TABELA HISTORII ZWROTÓW
   ============================================================ */
h3 + .wcwrfp-history,
.wcwrfp-history-wrapper h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--wcwrfp-color-text);
  margin: 0 0 12px;
}

table.wcwrfp-history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--wcwrfp-color-bg);
  border: 1px solid var(--wcwrfp-color-border);
  border-radius: var(--wcwrfp-radius);
  overflow: hidden;
  box-shadow: var(--wcwrfp-shadow-sm);
  margin-bottom: 24px;
}

table.wcwrfp-history thead th {
  background: var(--wcwrfp-color-surface);
  color: var(--wcwrfp-color-text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--wcwrfp-color-border);
}

table.wcwrfp-history tbody tr {
  border-bottom: 1px solid var(--wcwrfp-color-border);
  transition: background var(--wcwrfp-transition);
}

table.wcwrfp-history tbody tr:last-child {
  border-bottom: 0;
}

table.wcwrfp-history tbody tr:hover {
  background: var(--wcwrfp-color-surface);
}

table.wcwrfp-history tbody td {
  padding: 12px 14px;
  color: var(--wcwrfp-color-text);
  vertical-align: middle;
  line-height: 1.4;
}

/* ============================================================
   RESPONSYWNOŚĆ
   ============================================================ */
@media (max-width: 600px) {
  .wcwrfp-verify-form {
    padding: 20px 18px;
  }

  .wcwrfp-submit-form p:has(input[type="checkbox"]) {
    flex-direction: column;
    align-items: flex-start;
  }

  .wcwrfp-submit-form input[type="number"] {
    width: 80px;
  }

  table.wcwrfp-history {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wcwrfp-verify-form button[type="submit"],
  .wcwrfp-submit-form button[type="submit"] {
    width: 100%;
  }
}