/* ============================================
   Directiva Diseltec — Estilo tipo Apple
   Layout: login split, sidebar, tarjetas
   ============================================ */

:root {
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.1);
  --bg-body: #f5f5f7;
  --bg-sidebar: #fff;
  --bg-card: #fff;
  --border: rgba(0, 0, 0, 0.06);
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
}

/* ----- App layout (con sidebar) ----- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand i {
  font-size: 1.5rem;
  color: var(--accent);
}

.sidebar-brand-logo {
  width: 60%;
  max-width: 60%;
  height: auto;
  object-fit: contain;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Navegación: enlaces con icono (Bootstrap Icons) + texto */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.sidebar-link:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

/* Elemento activo: fondo en color primario (sin sombra ni borde lateral) */
.sidebar-link.active {
  background: rgba(0, 113, 227, 0.1);
  border-left-color: transparent;
  color: var(--accent);
  font-weight: 500;
  box-shadow: none;
}

.sidebar-link i {
  font-size: 1.2rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

/* Grupos colapsables del sidebar */
.sidebar-group {
  margin-top: 0.15rem;
}

.sidebar-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.sidebar-group-toggle:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.sidebar-group-chevron {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.sidebar-group-toggle.sidebar-group-open .sidebar-group-chevron {
  transform: rotate(180deg);
}

.sidebar-group-menu {
  padding-left: 0.5rem;
  margin-top: 0.15rem;
  border-left: 1px solid var(--border);
  margin-left: 1rem;
}

.sidebar-group-menu .sidebar-link-sub {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}

.sidebar-group-menu .sidebar-link-sub:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.sidebar-group-menu .sidebar-link-sub.active {
  background: rgba(0, 113, 227, 0.1);
  border-left-color: transparent;
  color: var(--accent);
  font-weight: 500;
  box-shadow: none;
}

.sidebar-group-menu .sidebar-link-sub i {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0.5rem 0.6rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sidebar-footer .sidebar-link-logout {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.5rem !important;
}

.sidebar-footer .sidebar-link-logout i {
  font-size: 1rem;
  width: 1rem;
}

.sidebar-link-admin {
  flex-shrink: 0;
  padding: 0.4rem !important;
}

.sidebar-link-admin i {
  font-size: 0.95rem;
  width: 0.95rem;
}

.sidebar-logout-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.35;
}

.sidebar-logout-text .sidebar-user-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.sidebar-logout-text .sidebar-logout-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.topbar {
  height: var(--topbar-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-weight: 600;
  font-size: 1.1rem;
}

/* Botón menú hamburguesa: oculto en desktop */
.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.topbar-menu-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

/* Overlay móvil: oculto por defecto */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.content-area {
  flex: 1;
  padding: 1.5rem;
}

/* Listado de clientes (solo desktop): borde de la tarjeta tocando el borde del sidebar */
@media (min-width: 768px) {
  .content-area .clientes-list-wrap {
    margin-top: -1.5rem;
    /* Compensar padding .content-area (1.5rem) + gutter Bootstrap .container-lg (0.75rem) */
    margin-left: -2.25rem;
    padding-left: 0 !important;
  }
}

.messages-wrapper {
  margin-bottom: 1rem;
}

.page-header {
  margin-bottom: 0.5rem;
}

.page-header .display-6 {
  font-weight: 600;
}

/* ----- Tarjetas estilo Apple ----- */
.card-apple {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden;
}

.card-apple:hover {
  box-shadow: var(--shadow-hover);
}

.card-apple .card-body {
  padding: 1.5rem;
}

.card-apple .card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.card-apple .card-title {
  font-weight: 600;
  color: var(--text);
}

/* ----- Login DISELTEC: fondo blanco, card centrada, puntos grises ----- */
.login-page {
  overflow: hidden;
}

/* Fondo login: naranja vibrante + puntos grises en esquinas que se desvanecen al centro */
.login-page-diseltec .login-page-bg {
  min-height: 100vh;
  background: #FF662A;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  position: relative;
}

/* Puntos grises claros en esquina superior izquierda, desvaneciendo hacia el centro */
.login-dots {
  position: absolute;
  pointer-events: none;
}

.login-dots-tl {
  top: 0;
  left: 0;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 10px 10px, rgba(255, 255, 255, 0.65) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  background-position: 0 0;
  mask-image: linear-gradient(to bottom right, black 0%, black 25%, transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom right, black 0%, black 25%, transparent 70%);
}

/* Puntos en esquina inferior derecha, desvaneciendo hacia el centro */
.login-dots-br {
  bottom: 0;
  right: 0;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 10px 10px, rgba(255, 255, 255, 0.65) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  background-position: 0 0;
  mask-image: linear-gradient(to top left, black 0%, black 25%, transparent 70%);
  -webkit-mask-image: linear-gradient(to top left, black 0%, black 25%, transparent 70%);
}

.login-card-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
}

.login-card {
  display: flex;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.login-card-form {
  flex: 1;
  padding: 1.5rem 1.75rem 1.25rem;
  min-width: 0;
  background: #f5f7fa;
}

.login-logo {
  margin-bottom: 1.15rem;
}

.login-logo-img {
  display: block;
  height: 48px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  object-position: left center;
}

.login-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.login-label i {
  margin-right: 0.25rem;
  opacity: 0.8;
  font-size: 0.85rem;
}

.login-card-form .mb-3 {
  margin-bottom: 0.6rem !important;
}
.login-card-form .mb-4 {
  margin-bottom: 0.85rem !important;
}

.login-form .form-control,
.login-form .form-control:focus {
  border-radius: 8px;
  border-color: var(--border);
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
}

.btn-login-diseltec {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 8px;
  background: #2563eb;
  border: none;
  color: #fff;
  transition: background 0.2s;
}

.btn-login-diseltec:hover {
  background: #1d4ed8;
  color: #fff;
}

.login-card-info {
  width: 320px;
  min-width: 260px;
  background: #2563eb;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #fff;
  padding: 1.5rem 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  text-align: center;
}

.login-card-info::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 0;
}

.login-card-info .login-info-title,
.login-card-info .login-info-text,
.login-card-info .login-info-register {
  position: relative;
  z-index: 1;
}

.login-info-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.65rem 0;
  line-height: 1.3;
}

.login-info-text {
  font-size: 0.8rem;
  line-height: 1.55;
  margin: 0 0 1rem 0;
  opacity: 0.95;
  text-align: justify;
}

.login-info-register {
  font-size: 0.8rem;
  margin: 0;
  opacity: 0.95;
}

.login-info-register a {
  color: #fff;
  text-decoration: underline;
  font-weight: 600;
}

.login-info-register a:hover {
  color: rgba(255, 255, 255, 0.9);
}

/* Compatibilidad con layout antiguo si se usa en otra plantilla */
.login-split {
  display: flex;
  min-height: 100vh;
}

.login-split-left {
  flex: 1;
  background: linear-gradient(145deg, #1d1d1f 0%, #2d2d2f 50%, #1d1d1f 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 4rem;
}

.login-brand { margin-bottom: 3rem; }
.login-brand i { font-size: 3rem; color: #fff; opacity: 0.95; display: block; margin-bottom: 1rem; }
.login-brand h1 { font-size: 1.75rem; font-weight: 600; margin: 0 0 0.25rem 0; letter-spacing: -0.02em; }
.login-visual { margin-top: 2rem; }
.login-card-visual { background: rgba(255,255,255,0.08); border-radius: var(--radius-lg); padding: 2rem; max-width: 320px; text-align: center; }
.login-card-visual i { font-size: 2.5rem; color: rgba(255,255,255,0.9); display: block; margin-bottom: 0.75rem; }
.login-card-visual p { margin: 0; color: rgba(255,255,255,0.7); font-size: 0.95rem; }
.login-split-right { width: 480px; min-width: 400px; background: #fff; display: flex; align-items: center; justify-content: center; padding: 2rem; box-shadow: -4px 0 24px rgba(0,0,0,0.06); }
.login-form-wrapper { width: 100%; max-width: 360px; }
.login-form-wrapper h2 { font-weight: 600; font-size: 1.5rem; color: var(--text); }
.login-form .btn-primary { border-radius: var(--radius); font-weight: 500; padding: 0.75rem; background: var(--accent); border-color: var(--accent); }
.login-form .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.login-form-wrapper a { color: var(--accent); text-decoration: none; }
.login-form-wrapper a:hover { text-decoration: underline; }

/* ----- Responsive ----- */
@media (max-width: 991px) {
  .login-card {
    flex-direction: column;
  }

  .login-card-info {
    width: 100%;
    min-width: unset;
    padding: 2rem;
  }

  .login-split {
    flex-direction: column;
  }

  .login-split-left {
    padding: 2rem;
    min-height: 40vh;
  }

  .login-split-right {
    width: 100%;
    min-width: unset;
    flex: 1;
  }
}

@media (max-width: 575px) {
  .login-page-diseltec .login-page-bg {
    padding: 1rem;
  }

  .login-card-form {
    padding: 1.5rem;
  }

  .login-card-info {
    padding: 1.5rem;
  }

  .login-info-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 767px) {
  .topbar-menu-btn {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: none;
  }

  .app-layout.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }

  .app-layout.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .main-content {
    margin-left: 0;
  }

  .content-area {
    padding: 1rem;
  }

  /* En móvil el listado de clientes usa el padding normal; sin márgenes negativos para verse completo */
  .content-area .clientes-list-wrap {
    margin-top: 0;
    margin-left: 0;
    padding-left: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .content-area .clientes-list-wrap .card-apple {
    min-width: 0;
  }

  .content-area .clientes-list-wrap .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ----- Modal Nuevo usuario y Editar usuario (compacto) ----- */
.modal-usuario-nuevo .modal-dialog,
.modal-usuario-editar .modal-dialog {
  max-width: 340px;
}

.modal-usuario-nuevo .form-label,
.modal-usuario-editar .form-label {
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.modal-usuario-nuevo .form-control,
.modal-usuario-nuevo .form-select,
.modal-usuario-editar .form-control,
.modal-usuario-editar .form-select {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  min-height: 1.75rem;
}

.modal-usuario-nuevo .password-help {
  font-size: 0.65rem;
  margin-top: 0.2rem;
  line-height: 1.25;
  color: var(--text-muted);
}
