/**
 * KAR Energy Calculator - Modern Compact Dashboard
 * IA-KAR Green IT Solutions
 * Zero-scroll, 100% fluid responsive (no horizontal scrollbar)
 */

:root {
  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: #10b981;
  --primary-subtle: #ecfdf5;
  --primary-border: #a7f3d0;
  
  --secondary: #0284c7;
  --secondary-light: #38bdf8;
  --secondary-subtle: #f0f9ff;
  
  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-md: 0 3px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 6px 14px -2px rgba(15, 23, 42, 0.08);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.15s ease-in-out;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-sans);
  background-color: var(--slate-50);
  color: var(--slate-800);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(1000px 300px at 50% -50px, rgba(16, 185, 129, 0.06), transparent 70%),
    radial-gradient(800px 250px at 90% 0%, rgba(2, 132, 199, 0.04), transparent 60%),
    var(--slate-50);
}

/* RTL Support */
[dir="rtl"] {
  text-align: right;
  direction: rtl;
}

/* Main Container - Fully fluid with zero horizontal overflow */
.calc-container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 14px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Header - Ultra-compact 1-line Navbar */
.calc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--slate-200);
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.brand-wrapper {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo {
  height: 30px;
  width: auto;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: var(--slate-200);
  flex-shrink: 0;
}

.header-titles {
  min-width: 0;
}

.header-titles h1 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--slate-900);
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-titles p {
  font-size: 0.74rem;
  color: var(--slate-500);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-back-site {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--slate-600);
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-back-site:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

/* Language Picker */
.lang-dropdown {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.lang-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--slate-700);
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  white-space: nowrap;
}

.lang-dropdown-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.lang-flag {
  width: 16px;
  height: 11px;
  border-radius: 2px;
  object-fit: cover;
}

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--white);
  min-width: 160px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--slate-200);
  padding: 4px;
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
}

[dir="rtl"] .lang-menu {
  right: auto;
  left: 0;
}

.lang-dropdown.active .lang-menu {
  display: block;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 0.76rem;
  color: var(--slate-700);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.lang-item:hover, .lang-item.current {
  background: var(--primary-subtle);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Main Grid Layout - minmax(0, 1fr) prevents CSS Grid blowout */
.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 14px;
  align-items: start;
  width: 100%;
}

@media (max-width: 900px) {
  .calc-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Card Base */
.calc-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  min-width: 0;
}

/* Left Card (Parameters) */
.params-card {
  display: flex;
  flex-direction: column;
}

.calc-card-header {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--slate-100);
  padding-bottom: 6px;
}

.header-badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.header-badge-row h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-badge-row h3 svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
  flex-shrink: 0;
}

.btn-text-reset {
  background: none;
  border: none;
  color: var(--slate-400);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-text-reset:hover {
  color: var(--slate-900);
  background: var(--slate-100);
}

/* Presets Chips Inline */
.presets-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.presets-label-inline {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--slate-400);
  letter-spacing: 0.03em;
  margin-right: 2px;
}

.chip-btn {
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.chip-btn:hover {
  background: var(--primary-subtle);
  color: var(--primary-dark);
}

.chip-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary-hover);
}

/* Form Grid */
.form-compact-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-row-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.label-unit {
  font-size: 0.68rem;
  color: var(--slate-400);
  font-weight: 500;
  margin-left: 4px;
}

[dir="rtl"] .label-unit {
  margin-left: 0;
  margin-right: 4px;
}

/* Stepper Input - Compact */
.input-stepper {
  display: flex;
  align-items: stretch;
  background: var(--slate-50);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  height: 30px;
  overflow: hidden;
  transition: var(--transition);
  width: 100%;
}

.input-stepper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
  background: var(--white);
}

.stepper-btn {
  background: var(--slate-100);
  border: none;
  width: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  color: var(--slate-600);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
  flex-shrink: 0;
}

.stepper-btn:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.input-stepper input[type="number"],
.input-stepper input[type="text"] {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-900);
  text-align: center;
  outline: none;
  min-width: 0;
}

/* Select Control */
.select-wrapper {
  position: relative;
  width: 100%;
}

.select-control {
  width: 100%;
  height: 30px;
  padding: 0 22px 0 8px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--slate-800);
  background-color: var(--slate-50);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

[dir="rtl"] .select-control {
  padding: 0 8px 0 22px;
}

.select-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
  background: var(--white);
}

.select-arrow {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.65rem;
  color: var(--slate-400);
}

[dir="rtl"] .select-arrow {
  right: auto;
  left: 8px;
}

.custom-usage-fields {
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 6px 8px;
  background: var(--slate-100);
  border-radius: var(--radius-sm);
}

.custom-usage-fields.active {
  display: grid;
}

/* Slider Row */
.slider-row {
  margin-top: 2px;
}

.slider-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-val-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-subtle);
  padding: 1px 7px;
  border-radius: 999px;
}

.slider-container {
  display: flex;
  align-items: center;
  padding: 3px 0;
}

.range-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) 48%, var(--slate-200) 48%, var(--slate-200) 100%);
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}

/* Left Actions Panel (Integrated CTA) */
.left-actions-panel {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.actions-header-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--slate-400);
}

.primary-cta-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.secondary-cta-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}

.btn-action-buy, .btn-action-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-action-buy {
  background: var(--slate-900);
  color: var(--white);
}

.btn-action-buy:hover {
  background: var(--slate-800);
}

.btn-action-contact {
  background: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-300);
}

.btn-action-contact:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.compact-tools-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}

.btn-tool-compact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--slate-400);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-tool-compact:hover {
  color: var(--slate-900);
  background: var(--slate-100);
}

/* RIGHT COLUMN (Results Dashboard) */
.results-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Hero Banner - Highly Compact & Balanced */
.hero-results-banner {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 60%, #047857 100%);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  color: var(--white);
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hero-main-stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #a7f3d0;
  letter-spacing: 0.03em;
}

.hero-amount-wrapper {
  display: flex;
  align-items: baseline;
  gap: 3px;
  line-height: 1;
  margin: 3px 0 5px;
}

.hero-currency {
  font-size: 1.4rem;
  font-weight: 700;
  color: #a7f3d0;
}

.hero-amount {
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.hero-period {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.hero-monthly-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.2);
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  width: fit-content;
  white-space: nowrap;
}

/* Hero Side Metrics (KPI pills) */
.hero-side-metrics {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.side-stat-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.stat-pill-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-pill-icon.kwh {
  background: rgba(56, 189, 248, 0.25);
  color: #7dd3fc;
}

.stat-pill-icon.co2 {
  background: rgba(52, 211, 153, 0.25);
  color: #a7f3d0;
}

.stat-pill-content {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}

.stat-pill-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--white);
}

.stat-pill-val small {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.8;
}

.stat-pill-lbl {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.75);
}

/* Comparison Table Card - Compact */
.table-card {
  padding: 10px 12px;
  min-width: 0;
}

.table-card-header {
  margin-bottom: 6px;
}

.table-card-header h4 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 5px;
}

.comparison-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.76rem;
}

[dir="rtl"] .comparison-table {
  text-align: right;
}

.comparison-table th {
  padding: 5px 6px;
  background: var(--slate-100);
  color: var(--slate-600);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

.comparison-table th.th-savings {
  color: var(--primary-dark);
  background: var(--primary-subtle);
}

.comparison-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-800);
  white-space: nowrap;
}

.td-val-before {
  color: var(--slate-500);
}

.td-val-after {
  color: var(--slate-800);
  font-weight: 600;
}

.td-val-savings {
  color: var(--primary-dark);
  font-weight: 700;
  background: var(--primary-subtle);
}

/* Eco Strip Card - Compact Single Row */
.eco-strip-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.eco-strip-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #166534;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.eco-strip-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 600px) {
  .eco-strip-items {
    grid-template-columns: minmax(0, 1fr);
  }
}

.eco-pill {
  background: var(--white);
  border: 1px solid #dcfce7;
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.eco-pill-icon {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}

.eco-pill-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
}

.eco-pill-text strong {
  font-size: 0.8rem;
  font-weight: 800;
  color: #15803d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eco-pill-text small {
  font-size: 0.62rem;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer: Ultra-clean 1 line */
.calc-footer {
  text-align: center;
  padding: 8px 0 2px;
  color: var(--slate-400);
  font-size: 0.7rem;
  margin-top: auto;
}

.calc-footer a {
  color: var(--slate-500);
  text-decoration: none;
}

.calc-footer a:hover {
  text-decoration: underline;
}

/* Toast Message */
.toast-msg {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--slate-900);
  color: var(--white);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease-out;
  pointer-events: none;
  z-index: 1000;
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* Print Styles */
@media print {
  body {
    background: #ffffff !important;
  }
  
  .header-actions,
  .btn-text-reset,
  .presets-chips,
  .compact-tools-bar,
  .left-actions-panel {
    display: none !important;
  }
  
  .calc-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
  }
  
  .calc-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  
  .hero-results-banner {
    background: #064e3b !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
