/* =========================================
   1. RESET & VARIABLES (Modern System)
   ========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Fonts */
  --font-heading: "Outfit", sans-serif;
  --font-body: "Inter", sans-serif;

  /* Palette: Modern Slate & Emerald */
  --primary-color: #1e293b; /* Slate 800 */
  --secondary-color: #64748b; /* Slate 500 */
  --accent-color: #0ea5e9; /* Sky 500 */
  --accent-hover: #0284c7; /* Sky 600 */

  --success-color: #10b981; /* Emerald 500 */
  --warning-color: #f59e0b; /* Amber 500 */
  --danger-color: #ef4444; /* Red 500 */

  --bg-color: #f1f5f9; /* Slate 100 - Main Background */
  --sidebar-bg: #0f172a; /* Slate 900 - Sidebar */
  --card-bg: #ffffff;

  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-soft: 0 20px 25px -5px rgb(0 0 0 / 0.05);

  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: #334155; /* Slate 700 */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Typography Overrides */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--primary-color);
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* =========================================
   2. LAYOUT & SIDEBAR (Glassmorphism & Float)
   ========================================= */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
  transition: width 0.3s ease;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header h2 {
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  color: #94a3b8; /* Slate 400 */
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-item i {
  width: 24px;
  text-align: center;
  margin-right: 0.75rem;
  font-size: 1.1rem;
  transition: transform 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  padding-left: 1.25rem; /* Slide effect */
}

.nav-item:hover i {
  color: var(--accent-color);
  transform: scale(1.1);
}

.nav-item.active {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.nav-item.active i {
  color: white;
}

.sidebar-footer {
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* User Info Card in Sidebar */
.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-info i {
  font-size: 2rem;
  color: var(--accent-color);
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
  border-radius: 50%;
}

.user-info strong {
  display: block;
  font-size: 0.9rem;
  color: white;
}

.user-info small {
  color: #94a3b8;
  font-size: 0.8rem;
}

.logout-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.logout-btn:hover {
  background: var(--danger-color);
  color: white;
  border-color: var(--danger-color);
}

/* =========================================
   3. MAIN CONTENT & HEADER
   ========================================= */
.main-content {
  flex: 1;
  margin-left: 280px; /* Sidebar Width */
  padding: 3rem 4rem; /* More horizontal padding */
  max-width: 1800px;
}

.content-header {
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.content-header h1 {
  font-size: 2.25rem;
  margin-bottom: 0.25rem;
  color: var(--primary-color);
}

.breadcrumb {
  font-size: 0.9rem;
  color: var(--secondary-color);
  font-weight: 500;
}

.breadcrumb a {
  color: var(--secondary-color);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--accent-color);
}

.breadcrumb span {
  margin: 0 0.5rem;
  color: #cbd5e1;
}

/* =========================================
   4. CARDS & SECTIONS (Neumorphism-ish)
   ========================================= */
.stats-cards,
.dashboard-grid,
.recent-section,
.form-container,
.data-table,
.table-container-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

/* Dashboard Cards Specifics */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  background: transparent; /* Container is transparent */
  border: none;
  box-shadow: none;
}

.stat-card {
  background: var(--card-bg);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  border: 1px solid #f1f5f9;
}

.stat-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px; /* Squircle */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
}

/* Modern Gradient Icons */
.stat-primary .stat-icon {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0284c7;
}
.stat-success .stat-icon {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #059669;
}
.stat-info .stat-icon {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #4f46e5;
}
.stat-warning .stat-icon {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #d97706;
}

.stat-content h3 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.stat-content p {
  color: var(--secondary-color);
  font-weight: 500;
  font-size: 0.95rem;
}

/* =========================================
   5. BUTTONS & ACTIONS
   ========================================= */
.btn-primary,
.btn-secondary,
.btn-danger {
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.2);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(14, 165, 233, 0.3);
}

.btn-secondary {
  background: white;
  color: var(--primary-color);
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
}
.btn-danger:hover {
  background: var(--danger-color);
  color: white;
}

/* Quick Actions Grid */
.quick-actions h2,
.recent-section h2,
.table-header h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  color: var(--secondary-color);
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.action-btn i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--accent-color);
  transition: transform 0.2s;
}

.action-btn:hover {
  border-color: var(--accent-color);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.action-btn:hover i {
  transform: scale(1.1);
}

.action-btn span {
  font-weight: 600;
  color: var(--primary-color);
}

/* =========================================
   6. TABLES & LISTS (The Card Style)
   ========================================= */
.data-table {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid #f1f5f9;
  overflow: hidden;
}

.table-header {
  padding: 1.5rem 2rem;
  background: white;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-box {
  position: relative;
}
.search-box input {
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border-radius: 50px; /* Pill shape */
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  width: 280px;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.search-box input:focus {
  background: white;
  border-color: var(--accent-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}
.search-box i {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

/* Table Content */
.table-content {
  padding: 0;
}

.simple-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.simple-table th {
  background: #f8fafc;
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
}

.simple-table td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f8fafc; /* Very subtle border */
  vertical-align: middle;
  transition: background 0.1s;
}

.simple-table tr:last-child td {
  border-bottom: none;
}

.simple-table tr:hover td {
  background: #f8fafc;
}

/* User & Avatar Styles */
.user-cell {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.text-muted {
  color: #94a3b8;
}
.text-secondary {
  color: #64748b;
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.badge-info {
  background: #e0f2fe;
  color: #0284c7;
} /* Sky */
.badge-success {
  background: #dcfce7;
  color: #166534;
} /* Green */
.badge-warning {
  background: #fef3c7;
  color: #b45309;
} /* Amber */
.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
} /* Red */

/* Action Buttons Small */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
}
.btn-icon.btn-info {
  background: #38bdf8;
  box-shadow: 0 2px 4px rgba(56, 189, 248, 0.3);
}
.btn-icon.btn-danger {
  background: #fb7185;
  box-shadow: 0 2px 4px rgba(251, 113, 133, 0.3);
}
.btn-icon.btn-primary {
  background: var(--accent-color);
}

.btn-icon:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

/* =========================================
   7. FORMS (Clean Space)
   ========================================= */
.form-container {
  padding: 3rem;
  background: white;
  max-width: 900px;
  margin: 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

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

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

.form-group label.required::after {
  content: "*";
  color: var(--danger-color);
  margin-left: 4px;
}

.form-control {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s;
  background: #f8fafc;
}

.form-control:focus {
  background: white;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
  outline: none;
}

.form-actions {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 1.5rem;
}

/* =========================================
   8. MEDIA QUERIES
   ========================================= */
@media (max-width: 1024px) {
  .sidebar {
    width: 80px;
  }
  .sidebar-header h2 span,
  .nav-item span,
  .user-info div,
  .sidebar-footer small {
    display: none;
  }
  .sidebar-header {
    justify-content: center;
    padding: 1.5rem 0.5rem;
  }
  .sidebar-nav {
    padding: 1rem 0.5rem;
  }
  .nav-item {
    justify-content: center;
    padding: 1rem 0;
  }
  .nav-item i {
    margin: 0;
    font-size: 1.3rem;
  }
  .nav-item:hover {
    padding-left: 0;
    background: rgba(255, 255, 255, 0.1);
  }
  .main-content {
    margin-left: 80px;
    padding: 2rem;
  }
  .user-info {
    justify-content: center;
    padding: 0.5rem;
  }
  .user-info i {
    margin: 0;
  }
}

@media (max-width: 768px) {
  .dashboard-wrapper {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding-bottom: 1rem;
  }
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 1rem;
    gap: 1rem;
  }
  .nav-item {
    flex-direction: column;
    font-size: 0.7rem;
    padding: 0.5rem 1rem;
    text-align: center;
  }
  .nav-item i {
    margin-bottom: 0.3rem;
  }
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

/* =========================================
   9. MODERN FORM COMPONENTS (Added for Aperturas)
   ========================================= */

/* Grid Layouts */
.form-grid.layout-3-col {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.form-grid.layout-2-col {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

/* Form Section Headers */
.section-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-title i { color: var(--accent-color); }

/* Input with Icon Wrapper */
.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon-wrapper .input-icon {
    position: absolute;
    left: 1rem;
    color: #94a3b8;
    z-index: 10;
}
.input-icon-wrapper input {
    padding-left: 2.8rem;
}

/* Results Dropdown */
.results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 5px;
}
.results-dropdown div {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}
.results-dropdown div:hover {
    background: #f8fafc;
    color: var(--accent-color);
}

/* Selected Item Badge */
.selected-badge {
    margin-top: 0.5rem;
    background: #e0f2fe;
    color: #0c4a6e;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #bae6fd;
}
.selected-badge button {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0 0.5rem;
}
.selected-badge button:hover { transform: scale(1.2); }

/* Radio Cards (Inhumacion/Exhumacion) */
.radio-group-modern {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.radio-card {
    position: relative;
    cursor: pointer;
}
.radio-card input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}
.btn-radio {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    color: #64748b;
    font-weight: 600;
    transition: all 0.2s;
}
.radio-card input:checked + .btn-radio {
    background: white;
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.2);
}
.radio-card:hover .btn-radio {
    border-color: #cbd5e1;
}

/* Divider & Alerts */
.form-divider {
    border: 0;
    border-top: 1px dashed #cbd5e1;
    margin: 2.5rem 0;
}

.form-alert-info {
    background: #f0f9ff;
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
    color: #0c4a6e;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Responsive fixes for forms */
@media (max-width: 768px) {
    .form-grid.layout-3-col, .form-grid.layout-2-col {
        grid-template-columns: 1fr;
    }
}

/* Fix for Search Dropdown Positioning */
.search-group {
    position: relative;
}

/* Table Alignment Fixes */
.simple-table {
    width: 100%;
    border-collapse: collapse;
}
.simple-table th, .simple-table td {
    text-align: left;
}
.simple-table th:last-child, .simple-table td:last-child {
    text-align: right;
}

/* Dashboard Headers Spacing */
.recent-card h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Force layout spacing for actions title if needed */
.dashboard-grid > h3, .main-content > h4 {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Compact Quick Actions Toolbar */
.quick-actions-toolbar {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.quick-actions-toolbar h2 {
    font-size: 1.1rem;
    margin: 0;
    margin-right: auto;
    white-space: nowrap;
    color: var(--secondary-color);
}

.toolbar-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-toolbar i {
    font-size: 1.1rem;
    color: var(--accent-color);
}

.btn-toolbar:hover {
    background: white;
    border-color: var(--accent-color);
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.15);
    transform: translateY(-2px);
    color: var(--accent-color);
}

/* Spacing Fix for Recent Activity Cards */
.recent-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
    padding: 2.5rem; /* Increased padding */
    height: 100%;
}

.recent-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 1rem;
}

/* Ensure headers have room */
.recent-card h3 {
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    /* border-bottom removed for cleaner look */
}
