/**
 * LightEFX Panel Calculator Styles
 *
 * Theme-agnostic styling using CSS custom properties.
 * Common variables loaded from variables.css.
 *
 * @package LightEFX_Plugin
 * @since   1.0.0
 */

/* ============================================================================
   Panel Calculator Specific Variables
   ========================================================================= */

:root {
  /* Input background - slightly different from surface */
  --lightefx-input-bg: rgba(0, 0, 0, 0.03);
  --lightefx-input-border: rgba(0, 0, 0, 0.15);

  /* Modal backdrop */
  --lightefx-backdrop: rgba(0, 0, 0, 0.6);

  /* Close button color */
  --lightefx-close-btn: #1a1a1a;
}

/* Dark theme adjustments - applies when prefers dark mode */
@media (prefers-color-scheme: dark) {
  :root:not(.light-theme):not([data-theme="light"]) {
    --lightefx-input-bg: rgba(255, 255, 255, 0.05);
    --lightefx-input-border: rgba(255, 255, 255, 0.15);

    --lightefx-close-btn: #ffffff;
  }
}

/* Explicit dark theme override */
body.dark-theme,
body.dark,
html[data-theme="dark"],
.dark-mode {
  --lightefx-input-bg: rgba(255, 255, 255, 0.05);
  --lightefx-input-border: rgba(255, 255, 255, 0.15);

  --lightefx-close-btn: #ffffff;
}

/* ============================================================================
   Modal & Wrapper
   ========================================================================= */

#starefx-calculator-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9998;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}

#starefx-calculator-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--lightefx-backdrop);
  z-index: 9998;
}

#starefx-calculator-content-wrapper {
  position: relative;
  background: transparent;
  padding: 20px;
  z-index: 9999;
  border-radius: 12px;
  margin: auto;
}

#starefx-close-modal {
  position: absolute;
  top: 0;
  right: 15px;
  font-size: 2.5em;
  font-weight: bold;
  color: var(--lightefx-close-btn);
  background: transparent;
  border: none;
  cursor: pointer;
  line-height: 1;
  z-index: 10000;
  padding: 0;
  margin: 0;
  transition: transform 0.2s, opacity 0.2s;
}

#starefx-close-modal:hover {
  transform: scale(1.1);
  opacity: 0.8;
}

#starefx-close-modal:focus {
  outline: 2px solid var(--lightefx-focus-outline);
  outline-offset: 4px;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 1350px;
  margin: 0 auto;
  transition: all .4s ease-in-out;
}

.top-row-wrapper {
  position: relative;
  display: flex;
  gap: 20px;
  align-items: stretch;
  width: 100%;
}

.project-summary-container {
  flex: 1;
}

/* ============================================================================
   Calculator Form
   ========================================================================= */

.calculator-container {
  position: relative;
  background: var(--lightefx-surface-primary);
  padding: 40px;
  border-radius: 12px;
  color: var(--lightefx-text-primary);
  box-sizing: border-box;
  max-height: 95vh;
  overflow-y: auto;
  flex: 1 1 480px;
  border: 1px solid var(--lightefx-border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calculator-container h2 {
  text-align: center;
  font-size: 2em;
  font-weight: bold;
  margin: 0 0 30px;
  letter-spacing: 1px;
  color: var(--lightefx-text-primary);
}

.input-group,
.options-group {
  margin-bottom: 20px;
}

label,
.group-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--lightefx-text-secondary);
  font-size: .9em;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 12px;
  background: var(--lightefx-input-bg);
  border: 1px solid var(--lightefx-input-border);
  border-radius: 8px;
  color: var(--lightefx-text-primary);
  font-size: 1em;
  box-sizing: border-box;
  transition: border-color 0.2s, background-color 0.2s;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: 2px solid var(--lightefx-focus-outline);
  outline-offset: 2px;
  border-color: var(--lightefx-accent);
}

input[type="number"]::placeholder,
input[type="text"]::placeholder {
  color: var(--lightefx-text-muted);
  opacity: 0.7;
}

.dimension-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.dimension-row .input-group {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.imperial-input-group {
  flex: 1;
  display: flex;
  gap: 10px;
}

.sqm-display {
  color: var(--lightefx-accent);
  text-align: center;
  font-weight: bold;
  padding: 0;
  margin: -10px 0 20px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-option,
.checkbox-wrapper {
  display: flex !important;
  align-items: center;
  word-break: keep-all;
}

.radio-option label,
.checkbox-wrapper label {
  margin: 0 0 0 10px;
  cursor: pointer;
  font-weight: normal;
  color: var(--lightefx-text-primary);
}

input[type="radio"],
input[type="checkbox"] {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: var(--lightefx-input-bg);
  margin: 0;
  border: 1px solid var(--lightefx-input-border);
  display: grid;
  place-content: center;
  width: 1.15em;
  height: 1.15em;
  transition: background-color 0.2s, border-color 0.2s;
}

input[type="radio"]:focus,
input[type="checkbox"]:focus {
  outline: 2px solid var(--lightefx-focus-outline);
  outline-offset: 2px;
}

input[type="radio"]::before,
input[type="checkbox"]::before {
  content: "";
  width: .65em;
  height: .65em;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
  box-shadow: inset 1em 1em var(--lightefx-accent);
}

input[type="radio"]:checked::before,
input[type="checkbox"]:checked::before {
  transform: scale(1);
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="radio"]::before {
  border-radius: 50%;
}

input[type="checkbox"] {
  border-radius: 4px;
}

input[type="checkbox"]::before {
  transform-origin: bottom left;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

#calculateBtn {
  width: 100%;
  padding: 15px;
  background: var(--lightefx-accent);
  color: var(--lightefx-accent-contrast);
  border: none;
  border-radius: 8px;
  font-size: 1.1em;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .3s, transform .2s;
  margin-top: 10px;
}

#calculateBtn:hover {
  background: var(--lightefx-accent-hover);
  transform: translateY(-1px);
}

#calculateBtn:active {
  transform: translateY(0);
}

#calculateBtn:focus {
  outline: 2px solid var(--lightefx-focus-outline);
  outline-offset: 2px;
}

/* ============================================================================
   Results, Visualizer & Pricing
   ========================================================================= */

.results-visual-container {
  flex: 2;
}

.additional-components-container {
  flex: 1;
}

#power_supply_results,
#batten_results,
#border_results,
#led_perimeter_results,
#price_results_wrapper {
  text-align: left;
  color: var(--lightefx-text-secondary);
}

.content-box {
  background: var(--lightefx-surface-primary);
  padding: 30px;
  border-radius: 12px;
  box-sizing: border-box;
  border: 1px solid var(--lightefx-border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.content-box h3 {
  color: var(--lightefx-text-primary);
  text-align: center;
  margin: 0 0 20px;
}

.result-block {
  padding: 15px;
  border-radius: 8px;
  margin-top: 0;
}

.result-block.error {
  background: rgba(217, 48, 48, 0.1);
  border-left: 5px solid var(--lightefx-error);
  color: var(--lightefx-error);
  font-weight: 500;
}

.result-block.success {
  background: transparent;
}

#text-results .result-header,
.result-header {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--lightefx-text-primary);
  margin-bottom: 8px;
}

.result-details {
  color: var(--lightefx-text-secondary);
  line-height: 1.6;
}

.result-details .info-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--lightefx-border-medium);
}

.info-block ul {
  padding-left: 20px;
  margin: 5px 0 0;
}

.info-block li {
  margin-bottom: 5px;
}

#visual-layout {
  margin-top: 20px;
}

.visual-header {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--lightefx-text-primary);
  margin-bottom: 15px;
}

.ceiling-wrapper {
  position: relative;
  box-sizing: border-box;
  margin: 80px auto;
  width: 100%;
}

.panel-grid {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 2px;
  background: var(--lightefx-accent);
  border: 1px solid var(--lightefx-accent);
}

.panel-div {
  background: var(--lightefx-surface-secondary);
  border: 1px solid var(--lightefx-accent);
}

.ceiling-boundary {
  position: absolute;
  top: 0;
  left: 0;
  background: transparent;
  box-sizing: border-box;
  border: 2px dashed var(--lightefx-border-strong);
}

.offset-label,
.cut-indicator {
  position: absolute;
  background: var(--lightefx-surface-primary);
  font-size: 12px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.offset-label {
  color: var(--lightefx-text-primary);
  border: 1px solid var(--lightefx-border-medium);
}

.cut-indicator {
  color: var(--lightefx-error);
  border: 1px solid var(--lightefx-error);
}

/* ============================================================================
   Pricing Table Styles
   ========================================================================= */

.price-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-size: 0.95em;
  background: var(--lightefx-surface-secondary);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--lightefx-border-light);
}

.price-breakdown-table thead {
  background: var(--lightefx-surface-tertiary);
}

.price-breakdown-table th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 700;
  color: var(--lightefx-accent-dark);
  border-bottom: 2px solid var(--lightefx-border-medium);
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.price-breakdown-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--lightefx-border-light);
  color: var(--lightefx-text-secondary);
}

.price-breakdown-table tbody tr:last-child td {
  border-bottom: none;
}

.price-breakdown-table tbody tr:hover {
  background: var(--lightefx-hover-bg);
}

.price-breakdown-table .item-desc {
  font-weight: 600;
  color: var(--lightefx-text-primary);
}

.price-breakdown-table .item-qty,
.price-breakdown-table .item-regular,
.price-breakdown-table .item-discount,
.price-breakdown-table .item-total {
  text-align: right;
  white-space: nowrap;
}

.price-breakdown-table .item-discount.has-discount {
  color: var(--lightefx-success);
  font-weight: 600;
}

.price-breakdown-table th.item-desc {
  text-align: left;
}

.price-breakdown-table th.item-qty,
.price-breakdown-table th.item-regular,
.price-breakdown-table th.item-discount,
.price-breakdown-table th.item-total {
  text-align: right;
}

/* ============================================================================
   Price Summary Styles
   ========================================================================= */

.price-summary-separator {
  border-top: 1px solid var(--lightefx-border-medium);
  margin: 20px 0 15px;
}

.price-total {
  padding: 15px 20px;
  background: var(--lightefx-surface-tertiary);
  border-radius: 8px;
  margin-top: 15px;
  border: 1px solid var(--lightefx-border-light);
}

.price-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 0;
}

.price-summary-row:last-child {
  margin-bottom: 0;
}

.price-summary-row .price-label {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--lightefx-text-secondary);
}

.price-summary-row .price-value {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--lightefx-text-primary);
}

.price-summary-row .price-value.strikethrough {
  text-decoration: line-through;
  color: var(--lightefx-text-muted);
  opacity: 0.7;
}

.price-summary-row.savings {
  color: var(--lightefx-success);
  border-top: 1px solid var(--lightefx-border-light);
  padding-top: 12px;
  margin-top: 5px;
}

.price-summary-row.savings .price-label,
.price-summary-row.savings .price-value {
  color: var(--lightefx-success);
}

.price-summary-row.final-total {
  border-top: 2px solid var(--lightefx-accent);
  padding-top: 15px;
  margin-top: 10px;
}

.price-summary-row.final-total .price-label,
.price-summary-row.final-total .price-value {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--lightefx-accent-dark);
}

/* ============================================================================
   Buttons
   ========================================================================= */

#add-to-my-quotes-btn {
  width: 100%;
  padding: 15px;
  background: var(--lightefx-accent);
  color: var(--lightefx-accent-contrast);
  border: none;
  border-radius: 30px;
  font-size: 1.1em;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .3s, transform .2s;
  margin-top: 20px;
}

#add-to-my-quotes-btn:hover {
  background: var(--lightefx-accent-hover);
  transform: translateY(-1px);
}

#add-to-my-quotes-btn:active {
  transform: translateY(0);
}

#add-to-my-quotes-btn:focus {
  outline: 2px solid var(--lightefx-focus-outline);
  outline-offset: 2px;
}

#add-to-my-quotes-btn:disabled {
  background: var(--lightefx-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.component-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.component-header-toggle .result-header {
  margin-bottom: 0;
}

.back-button {
  background: none;
  border: 1px solid var(--lightefx-border-medium);
  color: var(--lightefx-text-secondary);
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: .9em;
  font-weight: 600;
  margin-bottom: 20px;
  transition: all .2s;
}

.back-button:hover {
  background: var(--lightefx-hover-bg);
  border-color: var(--lightefx-border-strong);
  color: var(--lightefx-text-primary);
}

.back-button:focus {
  outline: 2px solid var(--lightefx-focus-outline);
  outline-offset: 2px;
}

/* ============================================================================
   Responsive Table Styles
   ========================================================================= */

@media (max-width: 768px) {
  .price-breakdown-table {
    font-size: 0.85em;
  }

  .price-breakdown-table th,
  .price-breakdown-table td {
    padding: 10px 6px;
  }

  .price-breakdown-table th {
    font-size: 0.8em;
  }

  .price-summary-row .price-label,
  .price-summary-row .price-value {
    font-size: 1em;
  }

  .price-summary-row.final-total .price-label,
  .price-summary-row.final-total .price-value {
    font-size: 1.2em;
  }
}

@media (max-width: 480px) {
  .price-breakdown-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .price-breakdown-table th.item-regular,
  .price-breakdown-table td.item-regular {
    display: none;
  }
}

/* ============================================================================
   General Responsive Styles
   ========================================================================= */

@media (max-width: 1024px) {
  .top-row-wrapper {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .dimension-row {
    flex-direction: column;
    gap: 0;
  }

  .calculator-container {
    padding: 20px;
  }

  .calculator-container h2 {
    font-size: 1.5em;
  }

  #starefx-calculator-content-wrapper {
    padding: 10px;
  }

  .content-box {
    padding: 20px;
  }
}
