/* ============================================================
   assets/css/app.css  –  SolarQuote design system
   Upravuj farby v :root, zvyšok nechaj tak
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Syne:wght@600;700&display=swap');

/* --- Farby – EDITUJ PODĽA BRANDINGU --- */
:root {
  --c-brand:        #16A34A;   /* zelená – hlavná akcentová */
  --c-brand-dark:   #15803D;
  --c-brand-light:  #DCFCE7;
  --c-blue:         #0EA5E9;
  --c-blue-dark:    #0284C7;
  --c-blue-light:   #E0F2FE;

  --c-bg:           #F8FAFC;
  --c-surface:      #FFFFFF;
  --c-surface-2:    #F1F5F9;
  --c-border:       #E2E8F0;
  --c-border-dark:  #CBD5E1;

  --c-text:         #0F172A;
  --c-text-2:       #475569;
  --c-text-3:       #94A3B8;

  --c-danger:       #EF4444;
  --c-danger-light: #FEE2E2;
  --c-warn:         #F59E0B;
  --c-warn-light:   #FEF3C7;
  --c-success:      #22C55E;
  --c-success-light:#DCFCE7;

  --radius:         10px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 12px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg:      0 12px 32px rgba(0,0,0,.1);

  --sidebar-w:      240px;
  --header-h:       60px;
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
}
a { color: var(--c-brand); text-decoration: none; }
a:hover { color: var(--c-brand-dark); }
img { max-width: 100%; display: block; }

/* --- Layout (sidebar + main) --- */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-text);
  color: #CBD5E1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--c-brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.sidebar-logo .logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.sidebar-logo .logo-text span { color: var(--c-brand); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-group { padding: 0 12px 8px; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #64748B;
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #94A3B8;
  transition: all .15s ease;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--c-brand); color: #fff; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.05);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 500; color: #E2E8F0; }
.user-role  { font-size: 11px; color: #64748B; }
.user-logout { margin-left: auto; font-size: 16px; color: #64748B; cursor: pointer; }
.user-logout:hover { color: var(--c-danger); }

/* Main content area */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top bar */
.topbar {
  min-height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 1050;
  flex-wrap: wrap;
}
.topbar-title { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; }
.topbar-sub { font-size: 13px; color: var(--c-text-3); margin-left: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Page content */
.page-body { padding: 28px; flex: 1; }

/* --- Cards --- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--c-border);
  gap: 12px;
}
.card-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 600; }
.card-body { padding: 22px; }

/* --- Štatistické dlaždice --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--c-text-3); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 700; }
.stat-delta { font-size: 12px; color: var(--c-text-3); }
.stat-card.brand { border-left: 3px solid var(--c-brand); }
.stat-card.blue  { border-left: 3px solid var(--c-blue); }
.stat-card.warn  { border-left: 3px solid var(--c-warn); }

/* --- Tabuľky --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-3);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
table.data tbody tr { border-bottom: 1px solid var(--c-border); }
table.data tbody tr:hover { background: var(--c-surface-2); }
table.data tbody td { padding: 11px 14px; vertical-align: middle; }
table.data tbody tr:last-child { border-bottom: none; }

/* --- Tlačidlá --- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 500;
  border: none; cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--c-brand); color: #fff; }
.btn-primary:hover { background: var(--c-brand-dark); color: #fff; }
.btn-secondary { background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); }
.btn-secondary:hover { background: var(--c-border); }
.btn-blue { background: var(--c-blue); color: #fff; }
.btn-blue:hover { background: var(--c-blue-dark); color: #fff; }
.btn-danger { background: var(--c-danger-light); color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Formuláre --- */
.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--c-text-2); }
.form-label .req { color: var(--c-danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--c-border-dark);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; color: var(--c-text);
  background: var(--c-surface);
  transition: border .15s ease, box-shadow .15s ease;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
.form-control:disabled { background: var(--c-surface-2); color: var(--c-text-3); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.form-hint { font-size: 12px; color: var(--c-text-3); }
.form-error { font-size: 12px; color: var(--c-danger); }

/* --- Badge / stav --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-draft    { background: var(--c-surface-2); color: var(--c-text-3); }
.badge-sent     { background: var(--c-blue-light); color: var(--c-blue-dark); }
.badge-accepted { background: var(--c-success-light); color: #15803D; }
.badge-rejected { background: var(--c-danger-light); color: var(--c-danger); }
.badge-order    { background: #ede9fe; color: #6d28d9; }
.badge-realized { background: #ccfbf1; color: #0f766e; }

/* --- Flash správy --- */
.flash { padding: 12px 18px; border-radius: var(--radius); font-size: 14px; margin-bottom: 20px; border-left: 3px solid; }
.flash-success { background: var(--c-success-light); border-color: var(--c-success); color: #14532D; }
.flash-error   { background: var(--c-danger-light);  border-color: var(--c-danger);  color: #7F1D1D; }
.flash-warn    { background: var(--c-warn-light);    border-color: var(--c-warn);    color: #78350F; }

/* --- Modal --- */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 1200; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px;
  margin: 16px;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--c-border); }
.modal-title  { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 600; }
.modal-close  { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--c-text-3); padding: 4px; }
.modal-close:hover { color: var(--c-danger); }
.modal-body   { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 10px; }

/* --- Wizard kroky --- */
.wizard-steps {
  display: flex; gap: 0; margin-bottom: 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.wizard-step {
  flex: 1; padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  font-size: 13px; font-weight: 500; color: var(--c-text-3);
}
.wizard-step:last-child { border-right: none; }
.wizard-step.active { background: var(--c-brand-light); color: var(--c-brand-dark); }
.wizard-step.done   { background: var(--c-surface-2); color: var(--c-text-2); }
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.wizard-step.active .step-num { background: var(--c-brand); color: #fff; }
.wizard-step.done   .step-num { background: var(--c-success); color: #fff; }

/* --- Produktový konfigurátor --- */
.product-picker { display: flex; flex-direction: column; gap: 0; }
.product-row {
  display: grid;
  grid-template-columns: 1fr 90px 110px 110px 36px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
}
.product-row:last-child { border-bottom: none; }
.product-row.header { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-3); padding-bottom: 8px; }
.price-display { font-weight: 600; color: var(--c-brand); }

/* --- Strešné plochy --- */
.roof-card {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--c-surface-2);
  position: relative;
}
.roof-card-title { font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.roof-result {
  background: var(--c-brand-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 10px;
  display: none;
}
.roof-result.show { display: block; }
.roof-kwh { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; color: var(--c-brand-dark); }

/* --- Login page --- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E3A2F 100%);
  padding: 20px;
}
.login-box {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%; max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-title { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { font-size: 14px; color: var(--c-text-3); text-align: center; margin-bottom: 24px; }

/* --- Filter chips (scrollable pill bar) --- */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;        /* Firefox */
  padding-bottom: 2px;          /* priestor pre focus ring */
  margin-bottom: 20px;
}
.filter-chips::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.filter-chips .btn { flex-shrink: 0; }

/* --- Roof card gridy --- */
.roof-main-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.roof-2col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.orient-main-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: start;
}

/* --- Edit ponuky – 2-stĺpcový layout --- */
.edit-layout-grid {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 360px);
  gap: 24px;
  align-items: start;
}

/* Header ponuky – akcie (PDF, delete, späť) */
.quote-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Kontaktný riadok zákazníka – wrap namiesto overflow */
.quote-customer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--c-text-2);
  margin-top: 4px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .product-row { grid-template-columns: 1fr 70px; }
  .product-row .hide-mobile { display: none; }
  .hide-mobile { display: none !important; }

  /* Topbar – zobraz hamburger, kompaktné odsadenie */
  #menu-btn { display: block !important; }
  .topbar { padding: 8px 16px; gap: 10px; }
  .topbar-title { font-size: 15px; }

  /* Akcie topbaru – skry text, nechaj len ikony */
  .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn { padding: 7px 10px; }

  /* Edit ponuky – jednostĺpcový layout, pravý stĺpec hore */
  .edit-layout-grid {
    grid-template-columns: 1fr;
  }
  .edit-layout-grid > .edit-col-left  { order: 2; min-width: 0; }
  .edit-layout-grid > .edit-col-right { order: 1; min-width: 0; }

  /* Card header – zalamuj na mobile keď je nadpis + akcia príliš dlhé */
  .card-header { flex-wrap: wrap; gap: 8px 12px; }

  /* Wizard kroky – skry text etikety, nechaj len čísla */
  .wizard-step { padding: 12px 8px; justify-content: center; gap: 6px; }
  .wizard-step .step-label { display: none; }

  /* Mapa inštalácie – trochu vyššia na mobile pre pohodlné ťahanie */
  #inst-map { height: 200px !important; }

  /* Priestor pre browser chrome (Samsung heslo bar, gesture bar, adresný riadok) */
  .page-body { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

  /* Roof card gridy – jednostĺpcové na mobile */
  .roof-main-grid { grid-template-columns: 1fr; gap: 16px; }
  .roof-2col-grid  { grid-template-columns: 1fr; }
  .orient-main-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Hlavička ponuky – tlačidlá pod info zákazníka, horizontálne posuvné */
  .quote-main-header {
    flex-wrap: wrap;
    gap: 10px 12px;
  }
  .quote-main-header > div:first-child { width: 100%; }
  .quote-header-actions {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .quote-header-actions::-webkit-scrollbar { display: none; }
  .quote-header-actions .btn { flex-shrink: 0; white-space: nowrap; }
}

/* --- Stránkovanie --- */
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--c-border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  gap: 16px; flex-wrap: wrap;
}
.pg-info { font-size: 12px; color: var(--c-text-3); }
.pagination { display: flex; align-items: center; gap: 2px; }
.pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 4px;
  border-radius: 8px; border: none;
  font-size: 13px; font-weight: 500; color: var(--c-text-2);
  background: transparent; text-decoration: none;
  transition: background .12s, color .12s;
  cursor: pointer; line-height: 1;
}
.pg-btn:hover { background: var(--c-surface-2); color: var(--c-text-1); }
.pg-active {
  background: var(--c-brand) !important; color: #fff !important;
  font-weight: 700; box-shadow: 0 1px 4px rgba(22,163,74,.35);
}
.pg-active:hover { background: var(--c-brand-dark) !important; }
.pg-disabled { opacity: .3; pointer-events: none; }
.pg-dots { background: transparent !important; color: var(--c-text-3) !important; cursor: default; min-width: 20px; }
.pg-arrow { font-size: 16px; min-width: 34px; }

/* --- Utility --- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--c-text-3); }
.font-bold { font-weight: 600; }
.text-brand { color: var(--c-brand); }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }
