/* ============================================
   SISFE V2 - Custom Styles
   Mobile-first responsive + Dark/Light mode
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --sisfe-primary: #4361ee;
  --sisfe-primary-hover: #3a56d4;
  --sisfe-accent: #7209b7;
  --sisfe-success: #06d6a0;
  --sisfe-warning: #ffd166;
  --sisfe-danger: #ef476f;
  --sisfe-info: #118ab2;
  --sisfe-sidebar-width: 250px;
  --sisfe-bottomnav-height: 56px;
  --sisfe-transition: 0.25s ease;
}

/* --- z-index: NO elevar .app-main ---
   AdminLTE hierarchy: header(1034) < overlay(1037) < sidebar(1038).
   .app-main sin z-index para no tapar header dropdown ni sidebar.
   Modales BS5 usan position:fixed y escapan de overflow:auto sin problema. */

/* --- Logo --- */
.sisfe-logo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}

.sisfe-logo code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1em;
  font-weight: 800;
  background: none;
  color: var(--sisfe-primary);
  padding: 0;
}

[data-bs-theme="dark"] .sisfe-logo code {
  color: #7b9cff;
}

.sisfe-logo span {
  font-family: 'Source Sans 3', sans-serif;
  letter-spacing: 0.5px;
}

/* --- Auth pages logo (larger) --- */
.sisfe-logo-lg {
  font-size: 2rem;
}

.sisfe-logo-lg code {
  font-size: 1.15em;
}

/* --- Theme Toggle Button --- */
.theme-toggle {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 0.375rem;
  transition: background-color var(--sisfe-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle .bi {
  transition: transform 0.3s ease;
}

.theme-toggle:active .bi {
  transform: rotate(30deg);
}

/* --- Status Badges --- */
.badge-aprobado {
  background-color: var(--sisfe-success) !important;
  color: #000 !important;
}

.badge-rechazado {
  background-color: var(--sisfe-danger) !important;
  color: #fff !important;
}

.badge-encolado {
  background-color: var(--sisfe-info) !important;
  color: #fff !important;
}

.badge-borrador {
  background-color: #6c757d !important;
  color: #fff !important;
}

.badge-generado {
  background-color: var(--sisfe-warning) !important;
  color: #000 !important;
}

.badge-cancelado {
  background-color: #343a40 !important;
  color: #fff !important;
}

.badge-aprobado-obs {
  background-color: #20c997 !important;
  color: #000 !important;
}

/* --- Cards --- */
.card {
  border-radius: 0.5rem;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow var(--sisfe-transition);
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

[data-bs-theme="dark"] .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.card-header {
  border-radius: 0.5rem 0.5rem 0 0 !important;
  font-weight: 600;
}

/* --- Filter Cards (collapsible on mobile) --- */
.filter-card .card-body {
  transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
  overflow: hidden;
}

@media (max-width: 767.98px) {
  .filter-card .card-body.collapsed {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0;
  }

  .filter-card .card-body:not(.collapsed) {
    max-height: 500px;
    opacity: 1;
  }

  .filter-toggle-btn {
    display: inline-flex !important;
  }
}

@media (min-width: 768px) {
  .filter-card .card-body {
    max-height: none !important;
    opacity: 1 !important;
  }

  .filter-toggle-btn {
    display: none !important;
  }
}

.filter-toggle-btn {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

/* --- Tables responsive --- */
.table-responsive {
  border-radius: 0.375rem;
}

.table th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
}

@media (max-width: 767.98px) {
  .table {
    font-size: 0.85rem;
  }

  .table th,
  .table td {
    padding: 0.4rem 0.5rem;
  }
}

/* --- Touch-friendly action buttons --- */
.btn-action {
  min-height: 38px;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 767.98px) {
  .btn-action {
    min-height: 44px;
    min-width: 44px;
  }

  .btn-mobile-full {
    width: 100%;
  }
}

/* --- Pagination mobile --- */
@media (max-width: 575.98px) {
  .pagination .page-item.d-mobile-none {
    display: none !important;
  }

  .pagination .page-link {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .pagination-info {
    font-size: 0.8rem;
    text-align: center;
  }
}

/* --- Bottom Navigation (mobile only) --- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--sisfe-bottomnav-height);
  background-color: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  z-index: 1040;
  padding: 0;
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bottom-nav-item {
  flex: 1;
  text-align: center;
}

.bottom-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  color: var(--bs-secondary-color);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  gap: 2px;
  transition: color var(--sisfe-transition);
  min-height: var(--sisfe-bottomnav-height);
}

.bottom-nav-link .bi {
  font-size: 1.25rem;
}

.bottom-nav-link:hover,
.bottom-nav-link.active {
  color: var(--sisfe-primary);
}

@media (max-width: 767.98px) {
  .bottom-nav {
    display: block;
  }

  /* Add padding at bottom for content not to be hidden */
  .app-main {
    padding-bottom: calc(var(--sisfe-bottomnav-height) + 0.5rem);
  }

  /* Breadcrumb hidden on mobile */
  .breadcrumb {
    display: none !important;
  }

  /* App content header compact */
  .app-content-header {
    padding: 0.5rem 0;
  }

  .app-content-header h3 {
    font-size: 1.1rem;
  }

  /* Footer hidden on mobile (bottom nav takes its place) */
  .app-footer {
    display: none;
  }
}

/* --- Sidebar overlay on mobile --- */
@media (max-width: 991.98px) {
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1037;
    display: none;
  }

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

/* --- Auth pages --- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

[data-bs-theme="dark"] .auth-wrapper {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

[data-bs-theme="dark"] .auth-card {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-card .card-body {
  padding: 2rem;
}

@media (max-width: 575.98px) {
  .auth-card .card-body {
    padding: 1.5rem;
  }
}

.auth-card .form-control {
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
}

.auth-card .input-group-text {
  border-radius: 0.5rem 0 0 0.5rem;
  min-width: 44px;
  justify-content: center;
}

.auth-card .input-group .form-control {
  border-radius: 0 0.5rem 0.5rem 0;
}

.auth-btn {
  padding: 0.65rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--sisfe-primary);
  border-color: var(--sisfe-primary);
  transition: all var(--sisfe-transition);
}

.auth-btn:hover {
  background: var(--sisfe-primary-hover);
  border-color: var(--sisfe-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
}

/* --- Profile page --- */
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--sisfe-primary);
}

.empresa-card {
  border-left: 4px solid var(--sisfe-primary);
  transition: transform var(--sisfe-transition);
}

.empresa-card:hover {
  transform: translateX(4px);
}

/* --- Password strength indicator --- */
.password-strength {
  height: 4px;
  border-radius: 2px;
  margin-top: 0.5rem;
  background-color: var(--bs-secondary-bg);
  overflow: hidden;
  transition: all 0.3s ease;
}

.password-strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.password-strength-bar.weak {
  width: 25%;
  background-color: var(--sisfe-danger);
}

.password-strength-bar.fair {
  width: 50%;
  background-color: var(--sisfe-warning);
}

.password-strength-bar.good {
  width: 75%;
  background-color: var(--sisfe-info);
}

.password-strength-bar.strong {
  width: 100%;
  background-color: var(--sisfe-success);
}

/* --- Utility classes --- */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.min-h-44 {
  min-height: 44px;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--bs-secondary-color);
}

.empty-state .bi {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  margin: 0;
}

/* --- Smooth transitions for theme change --- */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Fix sidebar inheriting theme --- */
.app-sidebar {
  transition: background-color 0.3s ease;
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bs-secondary-bg);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bs-secondary-color);
}
