/* =====================================================
   SISTEMA DE INDICADORES - STYLE.CSS
   Version: 2.0 - Limpio y Organizado
   ===================================================== */

/* =====================================================
   Variables del tema
   ===================================================== */
:root {
  --primary-color: #145050;
  --accent-color: rgba(20, 80, 80, 0.85);
  --text-color: #333333;
  --glass-bg: rgba(255, 255, 255, 0.75);
  --card-bg: rgba(255, 255, 255, 0.5);
  --radius: 14px;
  --sidebar-width: 60px;
  --sidebar-expanded-width: 160px;
}

/* =====================================================
   Reset básico
   ===================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

/* =====================================================
   Body - Background con alineación top-center
   ===================================================== */
body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-color);
  background: url("/static/img/bg-default.jpg") no-repeat center center fixed;
  background-size: cover;
}

/* Overlay con blur sutil - SOLO para páginas internas (no login) */
body.with-blur::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 0;
}

/* =====================================================
   Contenedor principal
   ===================================================== */
.container {
  position: relative;
  z-index: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  transition: margin-left 0.3s ease;
}

.container.expanded {
  margin-left: var(--sidebar-expanded-width);
}

.center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* =====================================================
   Glass & tarjetas
   ===================================================== */
.glass {
  background: var(--glass-bg);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(6px);
}

/* =====================================================
   Login (SIN blur en el fondo)
   ===================================================== */
.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 2rem;
}

.login-card h1 {
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-size: 1.8rem;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius);
  outline: none;
  font-size: 1rem;
  background: white;
}

.login-card input:invalid {
  box-shadow: none;
}

.login-card button {
  width: 100%;
  padding: 0.9rem;
  border: none;
  border-radius: var(--radius);
  background: var(--primary-color);
  color: white;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.login-card button:hover {
  background: var(--accent-color);
}

/* Selector de empresas en login */
.empresa-selector {
  margin-bottom: 1.5rem;
  text-align: left;
}

.empresa-option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.empresa-option:hover {
  background: rgba(20, 80, 80, 0.05);
}

.empresa-option input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.empresa-option input[type="radio"]:checked + span {
  font-weight: 600;
  color: var(--primary-color);
}

.empresa-option:has(input:checked) {
  border-color: var(--primary-color);
  background: rgba(20, 80, 80, 0.1);
}

.error {
  color: #b91c1c;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: width 0.3s ease;
  z-index: 1000;
  border: none;
  border-radius: 0;
}

.sidebar.expanded {
  width: var(--sidebar-expanded-width);
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-color);
  padding: 0.6rem;
  border-radius: 8px;
  transition: background 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}

.icon-btn:hover {
  background: rgba(20, 80, 80, 0.1);
}

.icon-btn svg {
  min-width: 24px;
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.sidebar span {
  display: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.sidebar.expanded span {
  display: inline;
}

/* Usuario en sidebar */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--primary-color);
  padding: 0.6rem;
  border-radius: 8px;
  transition: background 0.2s ease;
  text-decoration: none;
  cursor: pointer;
}

.user-info:hover {
  background: rgba(20, 80, 80, 0.1);
}

.user-info svg {
  min-width: 24px;
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.user-info span {
  font-weight: 500;
}

.spacer {
  flex: 1;
}

/* =====================================================
   Grid de dashboards
   ===================================================== */
.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.dashboard-card {
  cursor: pointer;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.2s ease;
}

.dashboard-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.dashboard-card .icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.dashboard-card h2 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.dashboard-card p {
  font-size: 0.95rem;
  opacity: 0.8;
  line-height: 1.4;
}

.admin-card {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.admin-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.admin-card h2 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1.3rem;
}

.admin-card p {
  font-size: 0.95rem;
  opacity: 0.8;
}

/* =====================================================
   Viewer
   ===================================================== */
.viewer {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  background: var(--glass-bg);
  transition: left 0.3s ease;
  overflow: hidden;
  z-index: 1;
}

.viewer.expanded {
  left: var(--sidebar-expanded-width);
}

.viewer iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Corrección para Power BI (ocultar barra inferior) */
.viewer iframe[id="bi-frame"] {
  height: calc(100% + 38px);
  margin-bottom: -38px;
}

/* =====================================================
   Tablas de datos
   ===================================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
}

.data-table thead {
  background: rgba(20, 80, 80, 0.08);
}

.data-table th {
  padding: 0.9rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary-color);
  border-bottom: 2px solid rgba(20, 80, 80, 0.2);
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(20, 80, 80, 0.03);
}

/* Acciones en tablas */
.table-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.icon-btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn-small:hover {
  background: var(--accent-color);
  transform: scale(1.05);
}

.icon-btn-small.danger {
  background: #dc2626;
}

.icon-btn-small.danger:hover {
  background: #b91c1c;
}

.icon-btn-small svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* =====================================================
   Filtros Integrados Minimalistas
   ===================================================== */
.filtros-integrados {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 250px;
  padding: 0.6rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(20, 80, 80, 0.1);
}

.search-input::placeholder {
  color: #9ca3af;
}

.filter-select-inline {
  padding: 0.6rem 2rem 0.6rem 0.8rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  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='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 12px;
  outline: none;
  cursor: pointer;
  appearance: none;
  min-width: 150px;
  transition: all 0.2s ease;
}

.filter-select-inline:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(20, 80, 80, 0.1);
}

.filter-select-inline:hover {
  border-color: var(--primary-color);
}

.btn-limpiar {
  padding: 0.6rem 1.2rem;
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-limpiar:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

/* =====================================================
   Badges
   ===================================================== */
.badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-admin {
  background: #dc2626;
  color: white;
}

.badge-estandar {
  background: #2563eb;
  color: white;
}

.badge-visor {
  background: #6b7280;
  color: white;
}

.badge-super {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
}

.badge-empresa {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  margin: 0.1rem;
  background: rgba(20, 80, 80, 0.1);
  color: var(--primary-color);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-badge.activo {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.inactivo {
  background: #f3f4f6;
  color: #6b7280;
}

/* =====================================================
   Botones
   ===================================================== */
.btn-primary {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-color);
}

.btn-secondary {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  background: #6b7280;
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-small {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.2s ease;
  margin-right: 0.5rem;
}

.btn-small:hover {
  background: var(--accent-color);
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* =====================================================
   Formularios
   ===================================================== */
.form-card {
  max-width: 700px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--primary-color);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="color"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: white;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-color);
}

.form-group input[readonly] {
  background: #f3f4f6;
  cursor: not-allowed;
}

.form-group small {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* Checkboxes y radio buttons */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.5rem 0;
  max-height: 300px;
  overflow-y: auto;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.checkbox-label:hover {
  background: rgba(20, 80, 80, 0.05);
}

.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-label span {
  font-size: 0.95rem;
}

.checkbox-switch {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.checkbox-switch input[type="checkbox"] {
  width: 48px;
  height: 24px;
  cursor: pointer;
}

/* =====================================================
   Alertas
   ===================================================== */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* =====================================================
   Responsive: móvil
   ===================================================== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0.8rem;
    justify-content: space-between;
    position: fixed;
    bottom: 0;
    top: auto;
  }

  .sidebar.expanded {
    width: 100%;
  }

  .sidebar-content {
    flex-direction: row;
    margin-top: 0;
    gap: 0.5rem;
  }
  
  .user-info {
    margin-top: 0;
  }

  .container {
    margin-left: 0;
    margin-bottom: 70px;
    padding: 1rem;
  }

  .viewer {
    left: 0;
    top: 0;
    bottom: 70px;
  }
  
  .viewer iframe {
    height: 100%;
  }
  
  .viewer iframe[id="bi-frame"] {
    height: 104%;
  }

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

  .login-card {
    max-width: 100%;
    padding: 1.5rem;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .data-table {
    font-size: 0.85rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.7rem 0.5rem;
  }

  .filtros-integrados {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input {
    width: 100%;
    min-width: auto;
  }
  
  .filter-select-inline {
    width: 100%;
    min-width: auto;
  }
  
  .btn-limpiar {
    width: 100%;
  }
}

/* =====================================================
   Responsive: tablet
   ===================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .filtros-integrados {
    gap: 0.6rem;
  }
  
  .search-input {
    min-width: 200px;
  }
  
  .filter-select-inline {
    min-width: 130px;
  }
}