/* ═══════════════════════════════════════════════════════
   KNX Switch Configurator — Design Yourself
   style.css
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  --bg-main: #E8EAF0;
  --bg-panel: #FFFFFF;
  --bg-header: #FFFFFF;
  --color-primary: #C0392B;
  --color-accent: #E74C3C;
  --color-danger: #922B21;
  --color-text: #2C3E50;
  --color-muted: #8E9AAb;
  --color-border: #DDE2E8;
  --color-selected: #C0392B;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.18);
  --transition: 0.2s ease;
  --header-height: 120px;
  --variant-bar-height: 72px;
  --panel-width: 350px;
  --font: 'Inter', sans-serif;
}

/* ── Reset ── */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: var(--font);
  background-color: #f8f9fa;
  color: var(--color-text);
}

body {
  display: flex;
  flex-direction: column;
  zoom: 0.8; /* Webkit browsers */
  -webkit-transform-origin: top center;
  transform-origin: top center;
}

/* Firefox only scaling */
@-moz-document url-prefix() {
  body {
    transform: scale(0.8);
    transform-origin: top center;
  }
}

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

button { font-family: var(--font); cursor: pointer; border: none; outline: none; background: none; }
input { font-family: var(--font); outline: none; }
svg { display: block; flex-shrink: 0; }

/* ════════════════════════════════ HEADER ════════════════════════════════ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--color-border);
  padding: 0 20px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  flex: 1;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 60px; width: auto; }
.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.5px;
}
.logo-accent { color: var(--color-primary); }

.btn-home {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  border: 1.5px solid var(--color-border);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  height: 34px;
}
.btn-home:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Device Tabs */
.device-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.device-tab {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  border: 1.5px solid transparent;
}
.device-tab:hover { color: var(--color-text); background: #F0F2F5; }
.device-tab.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: rgba(192,57,43,0.07);
}
.device-tab.design-tab { color: var(--color-text); font-weight: 600; }
.device-tab.design-tab.active { color: var(--color-primary); }

.header-right {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  flex: 1;
  height: 100%;
  padding-bottom: 20px;
  gap: 12px;
}

.header-top-row {
  flex: 1;
  display: flex;
  align-items: center;
  padding-top: 15px;
}

.header-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-focus {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-text);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  transition: all var(--transition);
  height: 34px;
}
.btn-focus:hover { background: #F0F2F5; }
.btn-focus.active { background: var(--color-text); color: #fff; border-color: var(--color-text); }

.btn-pdf {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--color-danger);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-align: center;
  height: 34px;
}
.btn-pdf:hover { background: #C0392B; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(231,76,60,0.4); }
.btn-pdf span { white-space: nowrap; }

/* ════════════════════ VARIANT BAR ════════════════════ */
.variant-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: var(--variant-bar-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.variant-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #FAFAFA;
  color: var(--color-muted);
  transition: all var(--transition);
  padding: 6px;
}
.variant-btn:hover { border-color: var(--color-primary); color: var(--color-primary); background: rgba(192,57,43,0.06); }
.variant-btn.active {
  border-color: var(--color-primary);
  background: rgba(192,57,43,0.1);
  color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.2);
}
.variant-btn svg { width: 38px; height: 44px; }

/* ════════════════════════════ WORKSPACE ════════════════════════════ */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ════════════════════════════ PANELS ════════════════════════════ */
.panel {
  width: var(--panel-width);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-color: var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), opacity var(--transition);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.panel-left { border-right: 1px solid var(--color-border); }
.panel-right { border-left: 1px solid var(--color-border); }

/* Panel Tabs */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.panel-tab {
  flex: 1;
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  text-align: center;
}
.panel-tab:hover { color: var(--color-text); }
.panel-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.panel-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  background: #fdfdfd;
}

/* Panel Content */
.panel-content {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  gap: 12px;
}
.panel-content.active { display: flex; }
.panel-content::-webkit-scrollbar { width: 4px; }
.panel-content::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }

/* ─ Button Parts ─ */
.parts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.part-block {
  cursor: grab;
  transition: transform var(--transition), box-shadow var(--transition);
}
.part-block.full-width {
  grid-column: span 2;
}
.part-block:active { cursor: grabbing; }
.part-block:hover { transform: translateY(-2px); }
.part-block:hover .part-inner { box-shadow: var(--shadow-md); border-color: var(--color-primary); }

.part-inner {
  background: #F2F2F2;
  border: 1px solid #DDE1E3;
  border-radius: 8px;
  transition: all var(--transition);
  height: 50px; /* Base height for 1 row unit (A Buton) */
  width: 100%;
}
.part-inner.tall { height: 100px; } /* 2 rows high (B Buton) - This will look square in 2-col layout */
.part-inner.wide { height: 50px; } /* 1 row high, full width (C Buton) */
.part-inner.large { height: 100px; } /* 2 rows high, full width (D Buton) */

.parts-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-muted);
  margin-top: auto; /* Push to the bottom of the panel content */
  padding-bottom: 4px; /* Container padding-bottom is 16px, plus 4px = exactly 20px from bottom */
  background: var(--bg-panel);
  padding-top: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #EEF2F7;
}

/* ─ Icon & Text Panel ─ */
.no-button-selected {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  text-align: center;
  color: var(--color-muted);
  padding: 24px;
}
.no-button-selected p { font-size: 12px; line-height: 1.6; }

.button-editor { display: flex; flex-direction: column; gap: 16px; }

.region-editor {
  background: #F8FAFD;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}
.region-editor:hover { border-color: var(--color-primary); }

.region-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-muted);
}

.region-toggles {
  display: flex;
  gap: 4px;
}
.region-toggle {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  color: var(--color-muted);
  background: #fff;
  transition: all var(--transition);
}
.region-toggle:hover { border-color: var(--color-primary); color: var(--color-primary); }
.region-toggle.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.region-icon-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.region-icon-preview svg,
.region-icon-preview img { width: 28px; height: 28px; }

.icon-code-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  margin-left: 10px;
  font-family: var(--font);
}

.btn-select-icon {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: all var(--transition);
  background: rgba(192,57,43,0.06);
}
.btn-select-icon:hover { background: var(--color-primary); color: #fff; }

.region-text-input {
  width: 100%;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--color-text);
  background: #fff;
  transition: border-color var(--transition);
}
.region-text-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(192,57,43,0.15); }

/* ═════════════════════ RIGHT PANEL: TEXTURES ═════════════════════ */
.texture-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.texture-item {
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

.texture-swatch {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.1);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  cursor: pointer;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.texture-item.active .texture-swatch {
  border: 2px solid #2ecc71;
  box-shadow: var(--shadow-sm);
}

.swatch-controls {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}

.texture-item.active .swatch-controls {
  display: flex;
}

.inline-apply-btn {
  background: #fff;
  border: 1px solid #2c3e50;
  color: #2c3e50;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 65px;
}

.inline-apply-btn.active {
  background: #2c3e50;
  color: #fff;
}

.inline-apply-btn:hover {
  background: #f8f9fa;
}

.inline-apply-btn.active:hover {
  background: #1a252f;
}
.texture-pattern::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 2px, transparent 2px, transparent 8px);
}

/* ═════════════════════ RIGHT PANEL: ADVANCED COLOR PICKER ═════════════════════ */
.wall-color-section { display: flex; flex-direction: column; gap: 14px; }
.wall-color-label { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--color-muted); }

.advanced-picker {
  background: #fff;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  user-select: none;
  padding: 2px;
}

.picker-map {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.75;
  background-color: #f00;
  border-radius: 8px;
  cursor: crosshair;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

.picker-map-white { position: absolute; inset: 0; background: linear-gradient(to right, #fff, transparent); }
.picker-map-black { position: absolute; inset: 0; background: linear-gradient(to top, #000, transparent); }

.picker-pointer {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}

.picker-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.picker-preview-box {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background-image: conic-gradient(#eee 0.25turn, #fff 0.25turn 0.5turn, #eee 0.5turn 0.75turn, #fff 0.75turn);
  background-size: 10px 10px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.picker-preview-color { width: 100%; height: 100%; border-radius: 50%; }

.picker-sliders {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker-slider {
  position: relative;
  height: 12px;
  border-radius: 6px;
  cursor: pointer;
}

.hue-slider { background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }

.alpha-slider { position: relative; border-radius: 6px; overflow: hidden; height: 12px; }
.picker-slider-alpha-bg {
  position: absolute;
  inset: 0;
  background-image: conic-gradient(#eee 0.25turn, #fff 0.25turn 0.5turn, #eee 0.5turn 0.75turn, #fff 0.75turn);
  background-size: 8px 8px;
  z-index: 0;
}
.alpha-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, transparent, #f00);
  z-index: 1;
}

.picker-slider-handle {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
}

.picker-inputs {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.input-group input {
  width: 100%;
  padding: 6px 2px;
  border: 1px solid #e0e4e8;
  border-radius: 4px;
  text-align: center;
  font-size: 11px;
  font-family: var(--font-main);
  background: #fcfdfe;
  color: var(--color-text);
  outline: none;
}
.input-group input:focus { border-color: var(--color-primary); }

.input-group span { font-size: 10px; color: var(--color-muted); margin-top: 4px; font-weight: 600; }
.input-group.hex { flex: 2.2; }

#wallPresetColors {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid #f0f0f0;
}

.preset-color {
  aspect-ratio: 1;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.preset-color:hover { transform: scale(1.2); border-color: var(--color-primary); z-index: 2; }
.preset-color.active { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(192,57,43,0.3); }

/* ════════════════════ PREVIEW AREA ════════════════════ */
.preview-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: background var(--transition);
}

#previewScene {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  background-color: #E8E8E8;
  overflow: hidden;
}

/* Duvar boyası dokusu - Pseudo element ile daha garanti görünürlük */
#previewScene::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Kullanıcının yüklediği yeni yüksek çözünürlüklü doku */
  background-image: url('../images/ha11ok-white-1209552.jpg');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center center;
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 1;
  opacity: 0.8; /* Dokunun çok koyu olmaması için hafif şeffaflık */
}

.device-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 12px 40px rgba(0,0,0,0.22));
  transition: filter var(--transition);
  z-index: 2; /* Dokunun üstünde kalması için */
}

.device-frame {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
  /* default: Meteor Black */
  background: #111111;
  border: 4px solid #111111;
}

/* Grid cells */
.device-grid {
  display: grid;
  gap: 3px;
  padding: 3px;
}

/* Grid base */
.device-grid {
  display: grid;
  gap: 3px;
  padding: 3px;
}

.grid-cell {
  background: #FFFFFF;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  transition: all var(--transition);
  overflow: hidden;
  border: 1.5px solid transparent;
  flex: 1;
}
.grid-cell:hover { border-color: rgba(192,57,43,0.4); background: #FAFBFF; }
.grid-cell.selected {
  border-color: var(--color-selected) !important;
  box-shadow: 0 0 0 2px rgba(192,57,43,0.3), inset 0 0 12px rgba(192,57,43,0.1);
}
.grid-cell.drop-hover { border-color: var(--color-primary) !important; background: rgba(192,57,43,0.08) !important; }

/* Cell content areas */
.cell-region {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  transition: all var(--transition);
}
.cell-region svg { width: 34px; height: 34px; }

/* Type A (1x1) - Default vertical stack is fine, but UI hides top/bottom */

/* Type B (1x2) - Vertical with 10px gaps */
.grid-cell.cell-type-b {
  flex-direction: column;
  justify-content: space-between;
}
.cell-type-b .region-top { padding-top: 20px; align-items: flex-start; }
.cell-type-b .region-center { flex: 1; }
.cell-type-b .region-bottom { padding-bottom: 20px; align-items: flex-end; }

/* Type C (2x1) & D (2x2) - Horizontal distribution */
/* Rules: Top/Right is actually on the RIGHT, Bottom/Left is on the LEFT */
.grid-cell.cell-type-c, .grid-cell.cell-type-d {
  flex-direction: row; /* Regions side by side? No, user said absolute positioning relative to center */
}

/* Reset regions for absolute layout in C & D */
.cell-type-c .cell-region, .cell-type-d .cell-region {
  position: absolute;
  width: auto;
  height: auto;
  top: 50%;
  transform: translateY(-50%);
}

.cell-type-c .region-center, .cell-type-d .region-center {
  left: 50%;
  transform: translate(-50%, -50%);
}

.cell-type-c .region-top, .cell-type-d .region-top {
  right: 20px;
  left: auto;
}

.cell-type-c .region-bottom, .cell-type-d .region-bottom {
  left: 20px;
  right: auto;
}

.cell-text {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}

/* Room controller LCD */
.room-ctrl-lcd {
  grid-column: 1 / -1;
  grid-row: span 2;
  background: #232323;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  height: 100%;
}
.room-ctrl-lcd img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ════════════════════════ ICON PICKER MODAL ════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 1100px;
  max-width: 95vw;
  height: 800px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
  overflow: hidden;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #F0F2F5;
  color: var(--color-muted);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: #E0E2E5; color: var(--color-text); }

.modal-search { padding: 12px 20px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.icon-search-input {
  width: 100%;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  color: var(--color-text);
  transition: border-color var(--transition);
}
.icon-search-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(74,159,213,0.15); }

.modal-categories {
  display: flex;
  gap: 6px;
  padding: 12px 20px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border);
}
.modal-categories::-webkit-scrollbar { height: 4px; }
.modal-categories::-webkit-scrollbar-thumb { background: var(--color-border); }

.cat-tab {
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1.5px solid var(--color-border);
  color: var(--color-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}
.cat-tab:hover { border-color: var(--color-primary); color: var(--color-primary); }
.cat-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.modal-icons {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  align-content: start;
}
.modal-icons::-webkit-scrollbar { width: 6px; }
.modal-icons::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }

.icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  background: #FAFAFA;
}
.icon-item:hover { background: rgba(74,159,213,0.08); border-color: var(--color-primary); }
.icon-item.selected { background: rgba(74,159,213,0.15); border-color: var(--color-primary); }
.icon-item svg { width: 56px; height: 56px; }
.icon-item span {
  font-size: 11px;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.3;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
.btn-cancel {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  border: 1.5px solid var(--color-border);
  transition: all var(--transition);
}
.btn-cancel:hover { background: #F0F2F5; color: var(--color-text); }
.btn-ok {
  padding: 8px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  transition: all var(--transition);
}
.btn-ok:hover { background: #A93226; box-shadow: 0 4px 12px rgba(192,57,43,0.4); }

/* PDF Modal Form */
.pdf-form {
  display: flex !important;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* PDF Report Template Styles */
#pdfReportTemplate {
  font-family: Arial, Helvetica, sans-serif !important;
  letter-spacing: 0.5px !important;
  line-height: 1.5 !important;
  white-space: nowrap !important;
}
#pdfReportTemplate h2 {
  font-size: 16px;
  font-weight: bold;
  color: #2C3E50;
  margin-bottom: 10px;
  border-bottom: 2px solid #C0392B;
  display: inline-block;
  white-space: nowrap !important;
}
.pdf-section { margin-bottom: 20px; }
.pdf-grid { display: grid; grid-template-columns: 120px 1fr; gap: 8px; font-size: 12px; }
.pdf-label { font-weight: bold; color: #7f8c8d; }

#pdfReportTemplate .pdf-icon-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f1f1;
}
#pdfReportTemplate .pdf-icon-visual {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fdfdfd;
  border: 1px solid #ebebeb;
  border-radius: 4px;
}
#pdfReportTemplate .pdf-icon-visual svg { width: 24px; height: 24px; color: #2C3E50; }
#pdfReportTemplate .pdf-icon-info { display: flex; flex-direction: column; }
#pdfReportTemplate .pdf-icon-pos { font-size: 11px; font-weight: bold; color: #2C3E50; }
#pdfReportTemplate .pdf-icon-code { font-size: 10px; color: #95a5a6; }

/* ════════════════════════ FOCUS MODE ════════════════════════ */
body.focus-mode .panel-left,
body.focus-mode .panel-right { 
  opacity: 0.05; 
  pointer-events: none; 
  user-select: none; 
  backdrop-filter: blur(4px);
  background: transparent !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

/* ════════════════════════ RESPONSIVE ════════════════════════ */
@media (max-width: 768px) {
  :root { --panel-width: 0px; }
  .panel { width: 0; overflow: hidden; opacity: 0; position: absolute; }
  .panel.mobile-open {
    width: 220px;
    opacity: 1;
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .panel-left.mobile-open { left: 0; }
  .panel-right.mobile-open { right: 0; }

  .device-tabs { gap: 2px; }
  .device-tab { font-size: 11px; padding: 6px 8px; }
  .btn-home, .btn-focus { display: none; }

  .device-grid[data-device="switch-8"] { width: 240px; height: 320px; }
  .device-grid[data-device="switch-12"] { width: 280px; height: 340px; }
  .device-grid[data-device="room-ctrl"] { width: 240px; height: 380px; }
}

/* PDF Loading Spinner */
.loading-spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
}
.loading-spinner-arc {
  width: 44px;
  height: 44px;
  border: 4px solid #f0f2f5;
  border-top: 4px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ════════════════════════ UTILITY ════════════════════════ */
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.25s ease; }

/* Drag ghost */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  opacity: 0.75;
  z-index: 9999;
  background: rgba(74,159,213,0.2);
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-sm);
}
