/* ═══════════════════════════════════════════════
   RC Solutions — Design System
   Fuente: Nunito (Google Fonts)
   Paleta: Azul marino profundo + verde esmeralda
   Mobile-first, dark sidebar
═══════════════════════════════════════════════ */

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

:root {
  --brand:        #1a56db;
  --brand-dark:   #1044b2;
  --brand-light:  #e8f0fe;
  --accent:       #059669;
  --accent-light: #d1fae5;
  --danger:       #dc2626;
  --warn:         #d97706;
  --sidebar-bg:   #0f172a;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --radius:       12px;
  --shadow:       0 2px 16px rgba(0,0,0,.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.14);
  --text:         #1e293b;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --surface:      #ffffff;
  --bg:           #f1f5f9;
  --font:         'Nunito', sans-serif;
  --font-display: 'Syne', sans-serif;
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
img { max-width: 100%; display: block; }

/* ── LAYOUT ──────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-logo .brand-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.3px;
  line-height: 1.2;
}

.sidebar-logo .brand-sub {
  font-size: .72rem;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .6rem;
}

.sidebar-nav {
  padding: .8rem 0;
  flex: 1;
}

.nav-section-label {
  font-size: .68rem;
  font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: .8rem 1.2rem .3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.2rem;
  color: rgba(255,255,255,.6);
  font-size: .88rem;
  font-weight: 600;
  border-radius: 0;
  transition: all .18s;
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
}

.nav-item.active {
  color: #fff;
  background: rgba(26,86,219,.25);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}

.nav-item svg, .nav-item i {
  width: 18px; font-size: 1rem;
  opacity: .8;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.07);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .7rem;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: .8rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.4); text-transform: capitalize; }

.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: .25rem;
  border-radius: 6px;
  transition: color .18s;
  font-size: 1rem;
}
.logout-btn:hover { color: #f87171; }

/* ── TOPBAR (mobile) ──────────────────────────── */
.topbar {
  display: none;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
}

.topbar .brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  color: #fff;
  font-size: 1.05rem;
}

.menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .3rem;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 190;
}

/* ── MAIN CONTENT ─────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 2rem;
  max-width: 100%;
}

/* ── PAGE HEADER ──────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.page-title span {
  display: block;
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── CARDS ────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body { padding: 1.4rem; }
.card-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
}

/* ── STAT CARDS ───────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--brand-light); color: var(--brand); }
.stat-icon.green  { background: var(--accent-light); color: var(--accent); }
.stat-icon.orange { background: #fef3c7; color: var(--warn); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }

.stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 3px;
}

/* ── BUTTONS ──────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 700;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }

.btn-success   { background: var(--accent); color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-ghost     { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-icon      { padding: .5rem; border-radius: 8px; }
.btn-sm        { padding: .38rem .8rem; font-size: .8rem; }

/* ── FORMS ────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
}

.form-label .req { color: var(--danger); }

.form-control, .form-select {
  width: 100%;
  padding: .6rem .9rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .18s, box-shadow .18s;
  outline: none;
  appearance: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: 1.1rem;
  padding-right: 2.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid .full { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  gap: .7rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── SEARCH BAR ───────────────────────────────── */
.search-bar {
  display: flex;
  gap: .6rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap i {
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .95rem;
}

.search-input-wrap .form-control {
  padding-left: 2.4rem;
}

/* ── TABLE ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}

thead th {
  text-align: left;
  padding: .7rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .14s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody td {
  padding: .8rem 1rem;
  color: var(--text);
  vertical-align: middle;
}

.td-muted { color: var(--text-muted); font-size: .82rem; }

.table-actions { display: flex; gap: .4rem; align-items: center; }

/* ── BADGES ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge-pendiente  { background: #fef3c7; color: #92400e; }
.badge-realizada  { background: var(--accent-light); color: #065f46; }
.badge-cancelada  { background: #fee2e2; color: #991b1b; }
.badge-blue       { background: var(--brand-light); color: #1e40af; }

/* ── ALERTS ───────────────────────────────────── */
.alert {
  padding: .9rem 1.1rem;
  border-radius: 8px;
  font-size: .87rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.2rem;
}

.alert-success { background: var(--accent-light); color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }

/* ── AGENDA CARDS ─────────────────────────────── */
.agenda-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.visit-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  border-left: 4px solid var(--border);
  transition: box-shadow .18s, transform .18s;
}

.visit-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.visit-card.pendiente  { border-left-color: var(--warn); }
.visit-card.realizada  { border-left-color: var(--accent); }
.visit-card.cancelada  { border-left-color: var(--danger); }

.visit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .7rem;
}

.visit-client { font-weight: 800; font-size: .95rem; color: var(--text); }
.visit-time   { font-size: .78rem; font-weight: 700; color: var(--text-muted); }
.visit-vendor { font-size: .8rem; color: var(--text-muted); margin: .3rem 0; }
.visit-obj    { font-size: .82rem; color: var(--text); margin-top: .4rem; }

.visit-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .9rem;
  padding-top: .7rem;
  border-top: 1px solid var(--border);
}

/* ── DATE NAV ─────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.date-nav input[type=date] {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: .45rem .8rem;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--text);
  outline: none;
}

.date-nav input[type=date]:focus { border-color: var(--brand); }

/* ── LOGIN PAGE ───────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(26,86,219,.25) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(5,150,105,.15) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 1;
  animation: fadeUp .5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 1.8rem;
}

.login-logo .icon-wrap {
  width: 64px; height: 64px;
  background: var(--brand);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: .8rem;
  box-shadow: 0 8px 24px rgba(26,86,219,.4);
}

.login-logo .title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.login-logo .subtitle {
  font-size: .8rem;
  color: rgba(255,255,255,.45);
  margin-top: 2px;
}

.login-box .form-label { color: rgba(255,255,255,.7); }

.login-box .form-control {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
  color: #fff;
}

.login-box .form-control::placeholder { color: rgba(255,255,255,.3); }
.login-box .form-control:focus {
  border-color: var(--brand);
  background: rgba(255,255,255,.12);
  box-shadow: 0 0 0 3px rgba(26,86,219,.3);
}

/* ── EMPTY STATE ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state i { font-size: 3rem; opacity: .4; display: block; margin-bottom: .8rem; }
.empty-state p { font-size: .9rem; }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open { display: block; }

  .topbar { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(var(--topbar-h) + 1rem);
  }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .page-title { font-size: 1.2rem; }

  table { font-size: .8rem; }
  thead th, tbody td { padding: .6rem .7rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-box { padding: 2rem 1.4rem; }
}

/* ── UTILITIES ────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: .82rem; }
.fw-bold      { font-weight: 700; }
.fw-black     { font-weight: 800; }
.mt-1  { margin-top: .4rem; }
.mt-2  { margin-top: .8rem; }
.mt-3  { margin-top: 1.2rem; }
.mb-0  { margin-bottom: 0; }
.gap-2 { gap: .5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
