/* ==========================================================================
   ISAPDV - MODERN MOBILE-FIRST DESIGN SYSTEM (Bootstrap 5 + Custom Tokens)
   ========================================================================== */

:root {
  --primary-color: #0d6efd;
  --primary-hover: #0b5ed7;
  --primary-subtle: #e7f1ff;
  --dark-slate: #0f172a;
  --surface-color: #ffffff;
  --bg-color: #f8fafc;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --touch-target: 48px;
  --bottom-nav-height: 64px;
  --header-height: 60px;
  --sidebar-width: 260px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Alpine Cloak & Display Overrides */
[x-cloak],
[style*="display: none"],
[style*="display:none"] {
  display: none !important;
}

/* Base resets & ergonomics */
html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-color);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Touch Targets: minimum 48px for tap comfort */
.btn-touch,
.nav-touch {
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Layout Shell */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
}

@media (min-width: 992px) {
  .main-wrapper {
    padding-bottom: 24px;
    margin-left: var(--sidebar-width);
  }
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
}

/* Desktop Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1030;
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  display: none;
  flex-direction: column;
}

@media (min-width: 992px) {
  .app-sidebar {
    display: flex;
  }
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 0.5rem;
  margin: 0.15rem 0.75rem;
  transition: all 0.15s ease-in-out;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus {
  color: var(--primary-color);
  background-color: var(--primary-subtle);
}

.sidebar-nav .nav-link.active {
  color: #ffffff;
  background-color: var(--primary-color);
}

.sidebar-nav .nav-link i {
  font-size: 1.2rem;
  margin-right: 0.75rem;
}

/* Mobile Bottom Navigation (Fixed) */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-color);
  z-index: 1040;
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

@media (min-width: 992px) {
  .mobile-bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  height: 100%;
  padding: 4px 0;
  transition: color 0.15s ease;
  position: relative;
}

.bottom-nav-item i {
  font-size: 1.35rem;
  line-height: 1;
  margin-bottom: 2px;
}

.bottom-nav-item.active {
  color: var(--primary-color);
  font-weight: 600;
}

.bottom-nav-item.active::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 24px;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 2px;
}

/* Cards & Containers */
.card-modern {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-stat {
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

/* Quick Action Buttons for Touch */
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.75rem;
  border-radius: 1rem;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  transition: all 0.15s ease;
  text-align: center;
}

.quick-action-btn:hover,
.quick-action-btn:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.quick-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

/* Responsive Table / Hybrid List */
@media (max-width: 767.98px) {
  .table-responsive-hybrid thead {
    display: none;
  }
  .table-responsive-hybrid tbody,
  .table-responsive-hybrid tr,
  .table-responsive-hybrid td {
    display: block;
    width: 100%;
  }
  .table-responsive-hybrid tr {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.85rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  }
  .table-responsive-hybrid td {
    padding: 0.25rem 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .table-responsive-hybrid td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 0.5rem;
  }
}

/* Skeleton Loading Animation */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 0.375rem;
}

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

/* Badges */
.badge-subtle {
  font-weight: 600;
  padding: 0.35em 0.65em;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}
.badge-subtle-success {
  background-color: #d1fae5;
  color: #065f46;
}
.badge-subtle-primary {
  background-color: #e0f2fe;
  color: #0369a1;
}
.badge-subtle-warning {
  background-color: #fef3c7;
  color: #92400e;
}
.badge-subtle-danger {
  background-color: #fee2e2;
  color: #991b1b;
}
.badge-subtle-secondary {
  background-color: #f1f5f9;
  color: #475569;
}

/* Offcanvas More Menu */
.offcanvas-more {
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
}

@media (min-width: 992px) {
  .offcanvas-more {
    border-radius: 0;
  }
}

.more-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  border-radius: 0.75rem;
  color: var(--text-main);
  text-decoration: none;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  transition: all 0.15s ease;
  min-height: 80px;
}

.more-grid-item:hover,
.more-grid-item:active {
  background-color: var(--primary-subtle);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.more-grid-item i {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}
