/**
 * QR Config Panel - Modern UI Components
 *
 * Redesigned configuration panel for qr_payment_page.php
 * Uses existing brand system (pink gradients, glass effects, Inter font)
 */

/* =====================================================
   CONFIG PANEL LAYOUT
   ===================================================== */

.config-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.config-panel-header {
  padding: 1.25rem 1.5rem;
  background: var(--bg-white);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.config-panel-header h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-megadark);
  margin: 0 0 0.25rem 0;
  text-shadow: none;
}

.config-panel-header p {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
}

.config-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.config-panel-footer {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  text-align: center;
}

/* QR Selector */
.qr-selector {
  margin-bottom: 1rem;
}

.qr-selector-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-megadark);
  margin-bottom: 0.5rem;
  text-align: center;
}

.qr-selector-dropdown {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  display: block;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(213, 15, 126, 0.2);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-white);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.qr-selector-dropdown:focus {
  outline: none;
  border-color: var(--color-superdark);
  box-shadow: 0 0 0 3px rgba(213, 15, 126, 0.1);
}

/* =====================================================
   ACCORDION COMPONENT
   ===================================================== */

.accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.accordion-section {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  cursor: pointer;
  border-radius: var(--radius-lg);
  transition: all 0.2s ease;
  user-select: none;

  /* Glass effect - collapsed */
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(213, 15, 126, 0.1);
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.9);
}

.accordion-header.active {
  background: linear-gradient(135deg, rgba(213, 15, 126, 0.1), rgba(255, 54, 175, 0.05));
  border-left: 3px solid var(--color-superdark);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.accordion-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(213, 15, 126, 0.1) 0%, rgba(255, 54, 175, 0.05) 100%);
  border-radius: var(--radius-md);
  color: var(--color-superdark);
  margin-right: 0.75rem;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.accordion-title {
  flex: 1;
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.accordion-chevron {
  color: var(--text-muted);
  transition: transform 0.3s ease;
  font-size: 0.875rem;
}

.accordion-header.active .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out;
}

.accordion-content.open {
  max-height: 3000px; /* Large enough for any content */
}

.accordion-content-inner {
  background: var(--bg-white);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-top: none;
}

/* =====================================================
   TOGGLE SWITCH COMPONENT
   ===================================================== */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}

.toggle-row:not(:last-child) {
  border-bottom: 1px solid var(--bg-gray);
}

.toggle-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: #e5e7eb;
  border-radius: 13px;
  cursor: pointer;
  -webkit-transition: background 0.3s ease;
  transition: background 0.3s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  -webkit-transition: -webkit-transform 0.3s ease;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toggle-switch.active {
  background: linear-gradient(135deg, var(--color-superdark), var(--color-dark));
}

.toggle-switch.active::after {
  transform: translateX(22px);
}

/* Checkbox covers entire toggle for click handling */
.toggle-switch input[type="checkbox"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

/* =====================================================
   SEGMENTED CONTROL COMPONENT
   ===================================================== */

.segment-control {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid rgba(213, 15, 126, 0.1);
  margin: 0 auto;
}

.segment-control-wrapper {
  text-align: center;
  margin: 1rem 0;
}

.segment-option {
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.segment-option:hover {
  color: var(--color-superdark);
  background: rgba(213, 15, 126, 0.05);
}

.segment-option.active {
  background: linear-gradient(135deg, var(--color-superdark), var(--color-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(213, 15, 126, 0.3);
}

.segment-option i {
  font-size: 0.875rem;
}

/* Hidden radio inputs for form submission */
.segment-control input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* =====================================================
   WIDGET CARD COMPONENT
   ===================================================== */

.widget-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.widget-card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.widget-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.widget-card-header {
  display: flex;
  align-items: center;
  padding: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.widget-card-header:hover {
  background: var(--bg-light);
}

.widget-card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(213, 15, 126, 0.1) 0%, rgba(255, 54, 175, 0.05) 100%);
  border-radius: 10px;
  color: var(--color-superdark);
  margin-right: 0.75rem;
  font-size: 1rem;
  flex-shrink: 0;
}

.widget-card-title {
  flex: 1;
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.widget-card-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.widget-card.active .widget-card-content {
  max-height: 800px;
}

.widget-card-content-inner {
  padding: 1rem;
  background: var(--bg-light);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* =====================================================
   FORM COMPONENTS
   ===================================================== */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--bg-gray);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 48px;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-superdark);
  box-shadow: 0 0 0 3px rgba(213, 15, 126, 0.1);
}

.form-input::placeholder {
  color: var(--text-light);
}

.form-input:disabled {
  background: var(--bg-light);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-select {
  width: 100%;
  padding: 0.875rem 2.5rem 0.875rem 1rem;
  border: 1px solid var(--bg-gray);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-white);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 48px;
  box-sizing: border-box;
}

.form-select:focus {
  outline: none;
  border-color: var(--color-superdark);
  box-shadow: 0 0 0 3px rgba(213, 15, 126, 0.1);
}

/* Style dropdown options */
.form-select option {
  padding: 0.75rem 1rem;
  font-size: 15px;
  line-height: 1.5;
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 0.375rem;
  font-style: italic;
}

/* Inline form groups */
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 140px;
}

/* Ensure inputs take full width */
.form-group .form-input,
.form-group .form-select {
  width: 100%;
  box-sizing: border-box;
}

/* Amount input with currency prefix */
.amount-input-group {
  position: relative;
}

.amount-input-group .currency-prefix {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--font-size-sm);
  pointer-events: none;
}

.amount-input-group .form-input {
  padding-left: 2rem;
  text-align: right;
}

/* Amount options grid (A, B, C, D) */
.amount-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.amount-option {
  text-align: center;
}

.amount-option-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-superdark);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.amount-option .form-input {
  text-align: center;
  padding: 0.625rem 0.5rem;
}

/* Product list table */
.product-list {
  width: 100%;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-white);
  box-sizing: border-box;
}

.product-list-header {
  display: grid;
  grid-template-columns: 36px 90px minmax(0, 1fr);
  gap: 0;
  background: linear-gradient(135deg, rgba(213, 15, 126, 0.08) 0%, rgba(255, 54, 175, 0.04) 100%);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.product-list-header span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.7rem 0.75rem;
  border-right: 1px solid rgba(213, 15, 126, 0.1);
}

.product-list-header span:last-child {
  border-right: none;
}

.product-list-header .col-num {
  text-align: center;
  padding-left: 0;
  padding-right: 0;
}

.product-list-row {
  display: grid;
  grid-template-columns: 36px 90px minmax(0, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  transition: background-color 0.15s ease;
  align-items: stretch;
}

.product-list-row:last-child {
  border-bottom: none;
}

.product-list-row:hover {
  background: var(--bg-light, #f9fafb);
}

.product-list-row.has-data {
  background: rgba(213, 15, 126, 0.03);
}

.product-list-row.has-data:hover {
  background: rgba(213, 15, 126, 0.06);
}

.product-list-row .row-number {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-superdark);
  background: rgba(213, 15, 126, 0.05);
  border-right: 1px solid var(--border-color, #e5e7eb);
}

.product-list-row .input-wrapper {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  border-right: 1px solid var(--border-color, #e5e7eb);
  min-width: 0;
}

.product-list-row .desc-wrapper {
  border-right: none;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}

.product-list-row .input-wrapper .input-prefix {
  padding-left: 0.6rem;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.product-list-row .form-input {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.75rem 0.6rem;
  font-size: 14px;
  height: auto;
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
}

.product-list-row .amount-wrapper .form-input {
  padding-left: 0.25rem;
  width: 100%;
  text-align: right;
  padding-right: 0.6rem;
}

.product-list-row .form-input:focus {
  box-shadow: inset 0 0 0 2px var(--color-superdark);
  background: white;
  outline: none;
}

.product-list-row .desc-input {
  border-radius: 0;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  -webkit-box-sizing: border-box !important;
  box-sizing: border-box !important;
  /* Safari fix */
  -webkit-appearance: none;
  appearance: none;
  display: block;
}

/* File upload */
.file-upload {
  position: relative;
}

.file-upload-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border: 2px dashed var(--bg-gray);
  border-radius: var(--radius-md);
  background: var(--bg-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-upload-label:hover {
  border-color: var(--color-superdark);
  background: rgba(213, 15, 126, 0.02);
}

.file-upload-icon {
  font-size: 1.5rem;
  color: var(--color-superdark);
  margin-bottom: 0.5rem;
}

.file-upload-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.file-upload-preview {
  max-height: 80px;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
}

/* Logo upload specific - Modern card style */
.logo-upload {
  text-align: center;
}

.logo-upload label[for="LogoToUpload"],
.logo-upload label[for="logo_file"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border: 2px dashed var(--bg-gray);
  border-radius: var(--radius-lg);
  background: var(--bg-light);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 120px;
}

.logo-upload label[for="LogoToUpload"]:hover,
.logo-upload label[for="logo_file"]:hover {
  border-color: var(--color-superdark);
  background: rgba(213, 15, 126, 0.03);
}

.logo-upload-preview {
  max-height: 70px;
  max-width: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.logo-upload-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-sm);
  color: var(--color-superdark);
  font-weight: 500;
}

.logo-upload-text i {
  font-size: 1rem;
}

.logo-upload .form-hint {
  margin-top: 0.5rem;
}

/* =====================================================
   SAVE BUTTON AREA
   ===================================================== */

.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  background: linear-gradient(135deg, var(--color-superdark), var(--color-dark));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(213, 15, 126, 0.3);
}

.save-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(213, 15, 126, 0.4);
}

.save-button:active {
  transform: translateY(0);
}

.save-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.save-button.saving {
  opacity: 0.8;
  cursor: wait;
}

.save-button.success {
  background: linear-gradient(135deg, #10b981, #34d399);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.save-button.error {
  background: linear-gradient(135deg, #ef4444, #f87171);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.save-timestamp {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.unsaved-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border-radius: 50%;
  margin-left: 0.5rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* =====================================================
   CONDITIONAL SECTIONS
   ===================================================== */

.conditional-section {
  display: none;
}

.conditional-section.visible {
  display: block;
}

/* =====================================================
   RESPONSIVE ADJUSTMENTS
   ===================================================== */

@media screen and (max-width: 768px) {
  .config-panel-body {
    padding: 0.75rem;
  }

  .accordion-header {
    padding: 0.875rem 1rem;
  }

  .accordion-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .accordion-content-inner {
    padding: 1rem;
  }

  .amount-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .segment-control {
    flex-wrap: wrap;
    justify-content: center;
  }

  .segment-option {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-xs);
  }

  .widget-card-header {
    padding: 0.875rem;
  }

  .widget-card-icon {
    width: 36px;
    height: 36px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row .form-group {
    min-width: 100%;
  }

  .product-list-header,
  .product-list-row {
    grid-template-columns: 32px 80px 1fr;
  }
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
