/* ============================================================
   Decogarden Visor — Design System + Theme
   ============================================================ */

/* ── Variables: modo claro ── */
:root {
  --bg-base:       #FAFBFC;
  --bg-surface:    #FFFFFF;
  --bg-surface-2:  #F3F4F6;
  --border:        #E5E7EB;
  --border-focus:  #4CAF35;

  --text-primary:   #0F172A;
  --text-secondary: #64748B;
  --text-muted:     #94A3B8;

  --accent-green:       #4CAF35;
  --accent-green-hover: #3A9428;
  --accent-green-light: #EAF7E3;
  --accent-blue:        #1B9DD9;
  --accent-blue-light:  #E2F3FB;
  --accent-amber:       #F59E0B;
  --accent-amber-light: #FEF3C7;
  --accent-red:         #EF4444;
  --accent-red-light:   #FEE2E2;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.07), 0 4px 6px -4px rgba(0,0,0,.05);

  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --transition: 150ms ease;
  --transition-md: 200ms ease;
  --topbar-h:   56px;
}

/* ── Variables: modo oscuro ── */
[data-theme="dark"] {
  --bg-base:       #0B1220;
  --bg-surface:    #111827;
  --bg-surface-2:  #1A2332;
  --border:        #1F2937;
  --border-focus:  #4CAF35;

  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;

  --accent-green-light: rgba(76,175,53,.15);
  --accent-blue-light:  rgba(27,157,217,.15);
  --accent-amber-light: rgba(245,158,11,.15);
  --accent-red-light:   rgba(239,68,68,.15);

  --shadow-sm: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.35), 0 2px 4px -2px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.35), 0 4px 6px -4px rgba(0,0,0,.25);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  margin: 0;
  padding-top: var(--topbar-h);
  transition: background var(--transition-md), color var(--transition-md);
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  transition: background var(--transition-md), border-color var(--transition-md);
}

.topbar-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 1rem;
  gap: .75rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-green);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.brand-text {
  font-weight: 600;
  font-size: .9375rem;
  color: var(--text-primary);
}

.brand-sub {
  font-size: .8125rem;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar-center { flex: 1; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-shrink: 0;
}

/* ── Icon buttons ── */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1rem;
  padding: 0;
  line-height: 1;
}

.btn-icon:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* ── User avatar ── */
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #fff;
  font-size: .6875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ── Bootstrap dropdown overrides ── */
.dropdown-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: .375rem;
  min-width: 160px;
}

.dropdown-item {
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .875rem;
  padding: .5rem .75rem;
  transition: background var(--transition);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.dropdown-divider { border-color: var(--border); margin: .25rem 0; }

.dropdown-item-text {
  display: block;
  padding: .375rem .75rem;
  color: var(--text-secondary) !important;
}

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 1.5rem; }

/* ── Forms ── */
.form-control,
.form-select {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: .9375rem;
  padding: .625rem .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-surface);
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(76,175,53,.15);
  color: var(--text-primary);
  outline: none;
}

.form-control::placeholder { color: var(--text-muted); }
.form-control.is-invalid { border-color: var(--accent-red); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

.form-label {
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .375rem;
}

/* Password field wrapper */
.input-password-wrapper {
  position: relative;
}

.input-password-wrapper .form-control {
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  right: .375rem;
  top: 50%;
  transform: translateY(-50%);
  border: none !important;
  background: transparent !important;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
}

.password-toggle:hover { color: var(--text-primary); background: transparent !important; }

/* ── Buttons ── */
.btn {
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: .9375rem;
  padding: .625rem 1.25rem;
  transition: all var(--transition);
  border: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent-green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-green-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76,175,53,.35);
}

.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-primary:focus-visible {
  outline: 3px solid rgba(76,175,53,.4);
  outline-offset: 2px;
}

.btn-outline-secondary {
  background: transparent;
  border: 1.5px solid var(--border) !important;
  color: var(--text-secondary);
}

.btn-outline-secondary:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

/* ── Alerts ── */
.alert {
  border-radius: var(--radius-md);
  font-size: .875rem;
  padding: .75rem 1rem;
  border: 1px solid transparent;
}

.alert-danger {
  background: var(--accent-red-light);
  border-color: rgba(239,68,68,.25);
  color: #B91C1C;
}

.alert-warning {
  background: var(--accent-amber-light);
  border-color: rgba(245,158,11,.3);
  color: #92400E;
}

.alert-success {
  background: var(--accent-green-light);
  border-color: rgba(16,185,129,.3);
  color: #065F46;
}

[data-theme="dark"] .alert-danger  { color: #FCA5A5; }
[data-theme="dark"] .alert-warning { color: var(--accent-amber); }
[data-theme="dark"] .alert-success { color: #6EE7B7; }

/* ── Toast notifications ── */
.flash-container {
  position: fixed;
  top: calc(var(--topbar-h) + .75rem);
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 380px;
  pointer-events: none;
}

.toast-notification {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: .875rem 1rem;
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: .875rem;
  animation: toastSlideIn 250ms ease forwards;
  pointer-events: all;
}

.toast-notification.toast-success { border-left: 3px solid var(--accent-green); }
.toast-notification.toast-danger  { border-left: 3px solid var(--accent-red);   }
.toast-notification.toast-warning { border-left: 3px solid var(--accent-amber); }
.toast-notification.toast-info    { border-left: 3px solid var(--accent-blue);  }

.toast-body  { flex: 1; display: flex; align-items: center; gap: .5rem; color: var(--text-primary); }
.toast-icon  { font-size: 1rem; }
.toast-icon-success { color: var(--accent-green); }
.toast-icon-danger  { color: var(--accent-red);   }
.toast-icon-warning { color: var(--accent-amber); }
.toast-icon-info    { color: var(--accent-blue);  }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: .125rem;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex-shrink: 0;
}

.toast-close:hover { color: var(--text-primary); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(1rem); }
}

/* ── Service chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .625rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}

.chip-jardineria { background: var(--accent-green-light); color: var(--accent-green); }
.chip-piscinas   { background: var(--accent-blue-light);  color: var(--accent-blue);  }
.chip-domestico  { background: var(--accent-amber-light); color: var(--accent-amber); }

/* ── Utilities ── */
.text-primary-app   { color: var(--text-primary)   !important; }
.text-secondary-app { color: var(--text-secondary) !important; }
.text-muted-app     { color: var(--text-muted)     !important; }
.bg-surface         { background: var(--bg-surface) !important; }
.tabular            { font-variant-numeric: tabular-nums; }

/* ── Auth page layout ── */
.auth-page {
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card { width: 100%; max-width: 400px; }

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.75rem;
}

.brand-name {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

/* Logo en login */
.auth-logo-img {
  max-width: 260px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Logo en topbar */
.topbar-logo {
  height: 34px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* ── Error icon ── */
.error-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-red-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Skeletons ── */
.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .875rem 1rem;
  margin-bottom: .5rem;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-surface-2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.mt-1 { margin-top: .5rem; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Filter placeholder ── */
.filter-placeholder {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  color: var(--text-muted);
  font-size: .875rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .brand-text, .brand-sub { display: none; }
  .flash-container { max-width: calc(100vw - 2rem); }
}
