/* ============================================================
   ARKLOS PORTAL — Estilos principales
   Paleta: negro #1a1a1a, blanco #ffffff, gris #f5f5f3, acento #2563eb
   ============================================================ */

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

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

:root {
  --negro:        #1a1a1a;
  --blanco:       #ffffff;
  --gris-claro:   #f5f5f3;
  --gris-medio:   #e8e8e5;
  --gris-texto:   #6b7280;
  --acento:       #1a1a1a;
  --acento-hover: #333333;
  --exito:        #059669;
  --aviso:        #d97706;
  --error:        #dc2626;
  --info:         #2563eb;
  --radio:        8px;
  --radio-lg:     14px;
  --sombra:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --sombra-md:    0 4px 16px rgba(0,0,0,0.08);
  --font:         'DM Sans', sans-serif;
  --font-serif:   'DM Serif Display', serif;
  --transition:   0.18s ease;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--gris-claro);
  color: var(--negro);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }

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

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: var(--negro);
  color: var(--blanco);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo img {
  height: 32px;
}

.sidebar-user {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--blanco);
  margin-bottom: 2px;
}

.sidebar-user-empresa {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 16px 24px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}

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

.nav-item.activo {
  color: var(--blanco);
  background: rgba(255,255,255,0.10);
}

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

.nav-item svg {
  width: 18px; height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  background: none;
  border: none;
  padding: 0;
  width: 100%;
  transition: color var(--transition);
}

.btn-logout:hover { color: rgba(255,255,255,0.9); }

/* ── Contenido principal ── */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--blanco);
  border-bottom: 1px solid var(--gris-medio);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--negro);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 32px;
  flex: 1;
}

/* ── Tarjetas ── */
.card {
  background: var(--blanco);
  border: 1px solid var(--gris-medio);
  border-radius: var(--radio-lg);
  padding: 24px;
  box-shadow: var(--sombra);
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--negro);
}

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

.stat-card {
  background: var(--blanco);
  border: 1px solid var(--gris-medio);
  border-radius: var(--radio-lg);
  padding: 20px 24px;
  box-shadow: var(--sombra);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gris-texto);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--negro);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--gris-texto);
  margin-top: 4px;
}

/* ── Botones ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radio);
  font-size: 14px;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--negro);
  color: var(--blanco);
}
.btn-primary:hover { background: var(--acento-hover); }

.btn-secondary {
  background: var(--gris-claro);
  color: var(--negro);
  border: 1px solid var(--gris-medio);
}
.btn-secondary:hover { background: var(--gris-medio); }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-danger {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

/* ── Badges de estado ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-abierto    { background: #eff6ff; color: #1d4ed8; }
.badge-en_proceso { background: #fffbeb; color: #92400e; }
.badge-resuelto   { background: #f0fdf4; color: #166534; }
.badge-cerrado    { background: #f3f4f6; color: #374151; }
.badge-pendiente  { background: #fff7ed; color: #9a3412; }
.badge-completado { background: #f0fdf4; color: #166534; }
.badge-pendiente_cliente { background: #fdf4ff; color: #7e22ce; }
.badge-urgente    { background: #fef2f2; color: #991b1b; }
.badge-alta       { background: #fff7ed; color: #9a3412; }
.badge-normal     { background: #f0fdf4; color: #166534; }
.badge-baja       { background: #f3f4f6; color: #374151; }

/* ── Formularios ── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--negro);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gris-medio);
  border-radius: var(--radio);
  font-size: 14px;
  font-family: var(--font);
  color: var(--negro);
  background: var(--blanco);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--negro);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

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

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

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

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gris-texto);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--gris-medio);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gris-claro);
  color: var(--negro);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gris-claro); }

/* ── Flash messages ── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radio);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash-exito  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-aviso  { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.flash-info   { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gris-claro);
  padding: 24px;
}

.login-box {
  background: var(--blanco);
  border: 1px solid var(--gris-medio);
  border-radius: var(--radio-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--sombra-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img { height: 36px; }

.login-titulo {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitulo {
  font-size: 14px;
  color: var(--gris-texto);
  text-align: center;
  margin-bottom: 32px;
}

/* ── Vacio state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gris-texto);
}

.empty-state-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--negro);
  margin-bottom: 6px;
}

.empty-state-text { font-size: 14px; }

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

/* ============================================================
   MOBILE & PWA — Responsive completo
   ============================================================ */

/* ── Barra de navegación inferior (solo móvil) ── */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {

  /* Ocultar sidebar en móvil */
  .sidebar {
    display: none !important;
  }

  /* Contenido ocupa todo el ancho */
  .main-content {
    margin-left: 0 !important;
    padding-bottom: 72px; /* espacio para bottom nav */
  }

  /* Topbar móvil */
  .topbar {
    padding: 12px 16px;
  }

  .topbar-title {
    font-size: 16px;
  }

  .topbar-actions .btn {
    font-size: 12px;
    padding: 7px 12px;
  }

  /* Contenido */
  .page-content {
    padding: 16px 12px;
  }

  /* Stats grid en móvil */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-value {
    font-size: 22px;
  }

  /* Tarjetas */
  .card {
    padding: 16px;
    border-radius: 10px;
  }

  /* Tablas scroll horizontal */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 500px;
  }

  /* Formularios */
  .grid2, .grid3 {
    grid-template-columns: 1fr !important;
  }

  /* Tipo selector */
  .tipo-selector {
    grid-template-columns: 1fr !important;
  }

  /* Tabs scroll horizontal */
  .tabs-cliente {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-cliente::-webkit-scrollbar { display: none; }

  /* Chat */
  .chat-layout {
    grid-template-columns: 1fr !important;
    height: calc(100vh - 140px);
  }
  .chat-sidebar { display: none; }

  /* Grid 2 columnas en detalle */
  div[style*="grid-template-columns:1fr 300px"],
  div[style*="grid-template-columns: 1fr 300px"],
  div[style*="grid-template-columns:1fr 280px"],
  div[style*="grid-template-columns: 1fr 280px"],
  div[style*="grid-template-columns:1.6fr 1fr"],
  div[style*="grid-template-columns: 1.6fr 1fr"] {
    display: block !important;
  }

  /* Barra navegación inferior ── */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--blanco);
    border-top: 1px solid var(--gris-medio);
    z-index: 200;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--gris-texto);
    font-size: 10px;
    font-weight: 500;
    gap: 3px;
    position: relative;
    transition: color 0.15s;
    min-height: 56px;
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
  }

  .bottom-nav-item.activo {
    color: var(--negro);
  }

  .bottom-nav-item.activo svg {
    stroke: var(--negro);
  }

  .bottom-nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 18px);
    background: #dc2626;
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Menú lateral en móvil — drawer */
  .mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
  }
  .mobile-menu-overlay.show { display: block; }

  .mobile-drawer {
    position: fixed;
    top: 0;
    left: -280px;
    bottom: 0;
    width: 280px;
    background: var(--negro);
    z-index: 301;
    transition: left 0.25s ease;
    overflow-y: auto;
  }
  .mobile-drawer.show { left: 0; }

  /* Login móvil */
  .login-box {
    padding: 32px 24px;
    margin: 16px;
    border-radius: 16px;
  }

  /* Header con hamburger en móvil */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--gris-claro);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 8px;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .bottom-nav { display: none !important; }
  .mobile-menu-overlay { display: none !important; }
}

/* PWA safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
  .main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}
.platform-version {
  font-size: 10px;
  line-height: 1.4;
  color: rgba(255,255,255,0.32);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}