/* ================================================
   Sitruuna — yhteinen layout-komponentti
   Kaikki sivut käyttävät tätä
   ================================================ */

/* Google Fonts — sama kuin siivouspalvelusitruuna.fi */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Condensed:wght@300;400;700&display=swap');

:root {
  /* Sitruuna viralliset värit (sivustolta) */
  --green:          #5BAD2A;
  --green-dark:     #3B7A18;
  --green-deep:     #2d5e10;
  --green-light:    #EAF5D8;
  --green-mid:      #C0DD97;
  --green-pale:     #f4f7f0;

  --amber:          #E2A020;
  --amber-light:    #FEF3DC;
  --amber-dark:     #854F0B;
  --red:            #E05555;
  --red-light:      #FEECEC;
  --blue:           #2A7EBA;
  --blue-light:     #E6F2FB;
  --blue-dark:      #185FA5;

  --text:           #2c2c2c;
  --text-muted:     #6b7c5a;
  --text-light:     #aab89a;

  --bg:             #f4f7f0;
  --white:          #ffffff;
  --off-white:      #f7f9f3;
  --border:         #daeab8;

  --shadow-sm:      0 2px 8px rgba(59,122,24,0.08);
  --shadow:         0 2px 16px rgba(59,122,24,0.10);
  --shadow-lg:      0 8px 32px rgba(59,122,24,0.18);

  --radius-xs:      4px;
  --radius-sm:      8px;
  --radius:         14px;
  --radius-lg:      20px;
  --radius-full:    9999px;

  /* Fontit — Roboto kuten alkuperäisellä sivustolla */
  --font-sans:      'Roboto', system-ui, sans-serif;
  --font-condensed: 'Roboto Condensed', sans-serif;
  --font-mono:      'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* === APP SHELL === */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* === SIDEBAR === */
.sidebar {
  width: 230px; min-width: 230px;
  background: var(--green);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
}

.sidebar-header {
  padding: 0 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-logo-wrap {
  background: white;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: center;
  min-height: 80px;
}

.sidebar-logo {
  max-width: 160px;
  max-height: 56px;
  object-fit: contain;
}

.sidebar-logo-fallback {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
}

.sidebar-logo-fallback .brand {
  font-family: var(--font-condensed);
  font-size: 10px; font-weight: 400;
  color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase;
}

.sidebar-logo-fallback .company {
  font-family: var(--font-condensed);
  font-size: 20px; font-weight: 700;
  color: var(--text); letter-spacing: 0.02em;
}

.sidebar-user {
  padding: 12px 16px 0;
  display: flex; align-items: center; gap: 10px;
}

.sidebar-user .user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white; flex-shrink: 0;
}

.sidebar-user .user-name  { font-size: 13px; font-weight: 500; color: white; }
.sidebar-user .user-role  { font-size: 10px; color: rgba(255,255,255,0.65); }

.nav-section { padding: 10px 0; flex: 1; }

.nav-label {
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 18px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; font-size: 13px; font-weight: 400;
  cursor: pointer; color: rgba(255,255,255,0.82);
  transition: background 0.15s; border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover  { background: rgba(255,255,255,0.12); color: white; }
.nav-item.active { background: rgba(255,255,255,0.18); color: white; border-left-color: white; padding-left: 15px; font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 11px; color: rgba(255,255,255,0.5);
}

/* === MAIN AREA === */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* === TOPBAR === */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left { display: flex; flex-direction: column; }
.topbar-title { font-family: var(--font-condensed); font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.2; }
.topbar-sub   { font-size: 11px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.view-tabs { display: flex; gap: 3px; }
.view-tab {
  padding: 6px 14px; font-size: 12px; font-weight: 500;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; background: transparent; color: var(--text-muted);
  font-family: var(--font-sans); transition: all 0.15s;
}
.view-tab.active { background: var(--green); color: white; border-color: var(--green); }

/* === CONTENT === */
.content { flex: 1; overflow-y: auto; padding: 20px 24px; background: var(--bg); }

/* === CARDS === */
.card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.card-sm {
  background: var(--white); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 12px 14px;
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title  { font-family: var(--font-condensed); font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }

/* === STAT CARDS === */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

.stat-card {
  background: var(--white); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 14px 16px;
}

.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.02em; }
.stat-value { font-family: var(--font-condensed); font-size: 26px; font-weight: 700; color: var(--text); margin: 4px 0 2px; line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-muted); }
.stat-green .stat-value { color: var(--green); }
.stat-amber .stat-value { color: var(--amber); }
.stat-red   .stat-value { color: var(--red); }
.stat-blue  .stat-value { color: var(--blue); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: none;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary   { background: var(--green); color: white; box-shadow: 0 2px 8px rgba(59,122,24,0.2); }
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--green-light); color: var(--green-dark); border-color: var(--green-mid); }

.btn-danger    { background: var(--red); color: white; }
.btn-danger:hover { background: #c03030; }

.btn-ghost     { background: transparent; color: var(--green); border: none; }
.btn-ghost:hover { background: var(--green-light); }

.btn-sm   { padding: 6px 12px; font-size: 12px; }
.btn-lg   { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }

.btn-add {
  width: 100%; padding: 9px; border-radius: var(--radius-sm);
  border: 1px dashed var(--green-mid); background: transparent;
  cursor: pointer; font-size: 12px; font-family: var(--font-sans);
  color: var(--green); display: flex; align-items: center; justify-content: center;
  gap: 6px; margin-top: 10px; font-weight: 500; transition: background 0.15s;
}
.btn-add:hover { background: var(--green-light); }

/* === FORMS === */
.form-group  { margin-bottom: 14px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.form-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 5px;
  letter-spacing: 0.05em; text-transform: uppercase;
}

.form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font-sans); color: var(--text);
  background: var(--off-white); outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: var(--green); background: var(--white); box-shadow: 0 0 0 3px rgba(91,173,42,0.1); }
.form-input::placeholder { color: var(--text-light); }
.form-input.error { border-color: var(--red); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* === BADGES === */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: var(--radius-full); font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: var(--green-light);  color: var(--green-dark); }
.badge-amber  { background: var(--amber-light);  color: var(--amber-dark); }
.badge-red    { background: var(--red-light);    color: #a32d2d; }
.badge-blue   { background: var(--blue-light);   color: var(--blue-dark); }
.badge-gray   { background: #f0f0ec;             color: #888; }

/* === AVATAR === */
.avatar { display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.avatar-green { background: var(--green-light); color: var(--green-dark); }
.avatar-blue  { background: var(--blue-light);  color: var(--blue-dark); }
.avatar-amber { background: var(--amber-light); color: var(--amber-dark); }

/* === TAULUKKO === */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--green-pale); }

/* === LIST ROWS === */
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }

/* === TOGGLE === */
.toggle { width: 40px; height: 22px; border-radius: 11px; background: var(--border); position: relative; cursor: pointer; transition: background 0.2s; border: none; flex-shrink: 0; }
.toggle.on { background: var(--green); }
.toggle::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: white; top: 3px; left: 3px; transition: left 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.toggle.on::after { left: 21px; }

/* === TOAST === */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-80px); background: var(--text); color: white; padding: 10px 18px; border-radius: var(--radius-full); font-size: 13px; font-weight: 500; z-index: 9999; transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); white-space: nowrap; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg); pointer-events: none; }
.toast.show    { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green-dark); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--amber-dark); }

/* === MODAL/PANEL === */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 200; }
.overlay.open { display: block; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0.95);
  background: var(--white); border-radius: var(--radius-lg);
  padding: 24px; width: 480px; max-width: 95vw; z-index: 201;
  opacity: 0; transition: all 0.2s ease; max-height: 90vh; overflow-y: auto;
}
.modal.open { opacity: 1; transform: translate(-50%,-50%) scale(1); }

.modal-title { font-family: var(--font-condensed); font-size: 18px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.modal-close { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }

/* === ANIMAATIOT === */
@keyframes fadeUp   { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes spin     { to { transform:rotate(360deg); } }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:0.4} }
@keyframes bounce   { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

.animate-fadeUp { animation: fadeUp 0.35s ease both; }
.animate-fadeIn { animation: fadeIn 0.25s ease both; }

/* === SPINNER === */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner-green { border-color: var(--green-mid); border-top-color: var(--green); }

/* === MOBIILI BOTTOM NAV === */
.mobile-bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--border);
  z-index: 100; box-shadow: 0 -4px 16px rgba(0,0,0,0.05);
}
.mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 0; cursor: pointer; color: var(--text-muted); font-size: 10px; font-weight: 500; border: none; background: none; font-family: inherit; }
.mobile-nav-item.active { color: var(--green); }
.mobile-nav-icon { font-size: 20px; margin-bottom: 2px; }
.mobile-nav-dot  { width: 4px; height: 4px; border-radius: 50%; background: var(--green); margin-top: 2px; opacity: 0; }
.mobile-nav-item.active .mobile-nav-dot { opacity: 1; }

/* === TYPING === */
.typing { display: flex; gap: 4px; align-items: center; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

/* === AI STATUS === */
.ai-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.ai-dot.connected { background: var(--green); animation: pulse 2s infinite; }
.ai-dot.error { background: var(--red); }

/* === APULUOKAT === */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 6px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-green  { color: var(--green); }
.text-muted  { color: var(--text-muted); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--red); }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.p-md  { padding: 16px; }
.hidden { display: none; }

/* === RESPONSIIVISUUS === */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-bottom-nav { display: flex; }
  body { padding-bottom: 70px; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row  { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}
