/* =========================================================
   FONIA PARTNER PANEL — BASE STYLES
   Shared layout, sidebar, header, components, utilities
   ========================================================= */

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

/* ── CSS Variables ──────────────────────────────────────── */
:root {
  --accent:        #51D9D6;
  --accent-dark:   #3BC5C2;
  --accent-light:  rgba(81, 217, 214, 0.12);
  --accent-glow:   rgba(81, 217, 214, 0.25);

  --bg-app:        #F0F4F8;
  --bg-card:       #FFFFFF;
  --bg-card-hover: #FAFCFF;

  --sidebar-bg:    #0B1120;
  --sidebar-hover: #162033;
  --sidebar-active:#1e2f47;
  --sidebar-border: rgba(255,255,255,0.07);
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;

  --header-h:      64px;

  --text-primary:  #1A2336;
  --text-secondary:#5A6B85;
  --text-muted:    #94A3B8;
  --text-inverse:  #FFFFFF;

  --border:        #E4EAF2;
  --border-focus:  var(--accent);

  --success:       #10B981;
  --success-bg:    rgba(16,185,129,0.10);
  --warning:       #F59E0B;
  --warning-bg:    rgba(245,158,11,0.10);
  --danger:        #EF4444;
  --danger-bg:     rgba(239,68,68,0.10);
  --info:          #3B82F6;
  --info-bg:       rgba(59,130,246,0.10);

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:     0 10px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
  --shadow-accent: 0 8px 32px rgba(81,217,214,0.20);

  --transition:    0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* ── App Layout ─────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 800;
  color: #0b1120;
  letter-spacing: -0.5px;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-logo-text .brand {
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.3px;
}

.sidebar-logo-text .sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* User Info in Sidebar */
.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #0b1120;
  flex-shrink: 0;
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-info .name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .role-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.role-badge.partner {
  background: rgba(81,217,214,0.18);
  color: var(--accent);
}

.role-badge.reseller {
  background: rgba(59,130,246,0.18);
  color: #7CB5F7;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.28);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 8px;
  margin: 20px 0 6px;
}

.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.nav-item svg, .nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.85);
}

.nav-item:hover svg, .nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active svg, .nav-item.active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

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

.nav-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #0b1120;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-footer .nav-item {
  color: rgba(255,255,255,0.4);
}

.sidebar-footer .nav-item:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.08);
}

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

/* ── Top Header ─────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.page-title-area {
  flex: 1;
}

.page-title-area h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-title-area .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
}

/* ── Page Content ───────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding-right: 28px;
  box-sizing: border-box;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.card:hover {
  transform: translateY(-3px) scale(1.012);
  box-shadow: 0 8px 28px rgba(0,0,0,.10);
  border-color: var(--accent-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.card-header .card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body { padding: 24px; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition);
}

.stat-card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,.10);
  transform: translateY(-3px) scale(1.012);
  border-color: var(--accent-light);
}

.stat-card:hover::after { transform: scaleX(1); }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 4px;
}

.stat-icon.teal   { background: rgba(81,217,214,0.12); color: var(--accent-dark); }
.stat-icon.blue   { background: rgba(59,130,246,0.12); color: #3B82F6; }
.stat-icon.green  { background: rgba(16,185,129,0.12); color: #10B981; }
.stat-icon.amber  { background: rgba(245,158,11,0.12); color: #F59E0B; }
.stat-icon.purple { background: rgba(139,92,246,0.12); color: #8B5CF6; }

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-value.accent { color: var(--accent-dark); }

.stat-change {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: #F8FAFC;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #F0F4F8;
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: #F8FBFF; }

tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-muted {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── Badges / Status ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge.active    { background: var(--success-bg); color: var(--success); }
.badge.active .badge-dot { background: var(--success); }
.badge.inactive  { background: var(--danger-bg);  color: var(--danger); }
.badge.inactive .badge-dot { background: var(--danger); }
.badge.pending   { background: var(--warning-bg); color: var(--warning); }
.badge.pending .badge-dot { background: var(--warning); }
.badge.paid      { background: var(--success-bg); color: var(--success); }
.badge.paid .badge-dot { background: var(--success); }
.badge.unpaid    { background: var(--danger-bg);  color: var(--danger); }
.badge.unpaid .badge-dot { background: var(--danger); }
.badge.info      { background: var(--info-bg);    color: var(--info); }
.badge.info .badge-dot { background: var(--info); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0b1120;
  box-shadow: 0 2px 8px rgba(81,217,214,0.3);
}

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-app);
  color: var(--text-primary);
  border-color: #C8D4E0;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 12px;
}

.btn-ghost:hover {
  background: var(--bg-app);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.2);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-color: var(--accent);
}

/* ── Form Controls ──────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.form-control {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { appearance: none; cursor: pointer; }

/* ── Toolbar (search + filters) ─────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-box input {
  padding-left: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 15px;
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-text h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-header-text p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
}

/* ── Alert / Restricted Banner ──────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
}

.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-info    { background: var(--info-bg);    border: 1px solid rgba(59,130,246,0.2);  color: var(--info); }
.alert-warning { background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.2); color: #B45309; }
.alert-success { background: var(--success-bg); border: 1px solid rgba(16,185,129,0.2); color: #065F46; }
.alert-danger  { background: var(--danger-bg);  border: 1px solid rgba(239,68,68,0.2);  color: #991B1B; }

.alert strong { font-weight: 700; }

/* ── Divider ────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ── Pill Tabs ──────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--bg-app);
  border-radius: var(--radius);
  padding: 4px;
  gap: 2px;
  border: 1px solid var(--border);
  width: fit-content;
}

.tab {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.tab.active {
  background: #fff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tab:hover:not(.active) { color: var(--text-primary); }

/* ── Tooltips ───────────────────────────────────────────── */
[data-tooltip] { position: relative; }

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1A2336;
  color: #fff;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C8D4E0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #A0B0C0; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
}

/* ── Skeleton loader ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f4f8 25%, #e4eaf2 50%, #f0f4f8 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

/* ── Fade in ────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.35s ease both;
}

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

/* ── Topbar rango chip ──────────────────────────────────── */
.topbar-rango-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  background: var(--bg-app);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  max-width: 240px;
  position: relative;
  overflow: hidden;
}

.topbar-rango-chip:hover {
  border-color: var(--rango-color, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rango-color, var(--accent)) 15%, transparent);
  transform: translateY(-1px);
}

.topbar-rango-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.topbar-rango-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.topbar-rango-nombre {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--rango-color, var(--text-primary));
  white-space: nowrap;
  line-height: 1.2;
}

.topbar-rango-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  line-height: 1.2;
}

.topbar-rango-hint strong {
  color: var(--text-primary);
}

.topbar-rango-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border);
}

.topbar-rango-fill {
  height: 100%;
  background: var(--rango-color, var(--accent));
  border-radius: 0 99px 99px 0;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}
