/* ==========================================================================
   ICELAND AUDITORÍAS - SISTEMA DE DISEÑO & ESTILOS PRINCIPALES
   ========================================================================== */

:root {
  /* Paleta Sobria de Marca ICELAND */
  --primary-color: #1f3a37;
  --primary-hover: #162b29;
  --primary-light: #2c524e;
  --accent-gold: #d97706;
  
  /* Fondos y Superficies Cálidas */
  --bg-main: #f5f3f0;
  --bg-card: #ffffff;
  --bg-header: #faf8f5;
  --border-color: #e5e0d8;
  --border-hover: #d1c9bd;

  /* Texto */
  --text-main: #1c2826;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Colores de Estado de Auditoría */
  --status-closed-bg: #d1fae5;
  --status-closed-text: #065f46;
  --status-closed-border: #a7f3d0;

  --status-inprogress-bg: #fef3c7;
  --status-inprogress-text: #92400e;
  --status-inprogress-border: #fde68a;

  --status-pending-bg: #fee2e2;
  --status-pending-text: #991b1b;
  --status-pending-border: #fca5a5;

  --status-unaudited-bg: #f1f5f9;
  --status-unaudited-text: #475569;
  --status-unaudited-border: #e2e8f0;

  --status-overdue: #dc2626;

  /* Sombras y Efectos */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition-fast: 0.2s ease;
}

/* Modo Oscuro (Auto por Preferencia o Toggle Manual) */
body.dark-theme {
  --bg-main: #12181b;
  --bg-card: #1e262b;
  --bg-header: #182024;
  --border-color: #2e3a42;
  --border-hover: #3d4d57;

  --text-main: #e2e8f0;
  --text-muted: #94a3b8;

  --status-closed-bg: #064e3b;
  --status-closed-text: #a7f3d0;

  --status-inprogress-bg: #78350f;
  --status-inprogress-text: #fde68a;

  --status-pending-bg: #7f1d1d;
  --status-pending-text: #fca5a5;

  --status-unaudited-bg: #334155;
  --status-unaudited-text: #cbd5e1;
}

/* Resets Básicos */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 0.95rem;
  -webkit-font-smoothing: antialiased;
}

/* Layout General */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-body-container {
  display: flex;
  flex: 1;
}

/* Sidebar Navigation */
.app-sidebar {
  width: 260px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sidebar-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-link:hover {
  background-color: rgba(31, 58, 55, 0.08);
  color: var(--primary-color);
}

body.dark-theme .sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background-color: var(--primary-color);
  color: var(--text-inverse);
}

.sidebar-link.text-danger:hover {
  background-color: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

/* App Main Content */
.app-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background-color: var(--bg-main);
}

.btn-danger {
  background-color: #dc2626;
  color: #fff;
}

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

.btn-danger-soft {
  background-color: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.btn-danger-soft:hover {
  background-color: #dc2626;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* Tarjetas y Paneles */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Insignias Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-admin {
  background-color: rgba(217, 119, 6, 0.15);
  color: #d97706;
}

.badge-sucursal {
  background-color: rgba(31, 58, 55, 0.15);
  color: var(--primary-color);
}

body.dark-theme .badge-sucursal {
  color: #5eead4;
}

/* Modales */
/* Modales y Formularios */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.15rem;
}

.form-group label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.01em;
}

.form-control, .select-control {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.95rem;
  font-size: 0.94rem;
  font-family: inherit;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  color: var(--text-main);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.form-control:focus, .select-control:focus {
  border-color: var(--primary-color);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(31, 58, 55, 0.15);
}

body.dark-theme .form-control:focus,
body.dark-theme .select-control:focus {
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.2);
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.2rem;
}

.modal-card {
  background-color: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 1.5px solid var(--border-color);
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card.modal-lg {
  max-width: 820px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.6rem;
  border-bottom: 1.5px solid var(--border-color);
  background-color: var(--bg-header);
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--text-main);
}

body.dark-theme .modal-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-body {
  padding: 1.6rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1.1rem 1.6rem;
  border-top: 1.5px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.85rem;
  background-color: var(--bg-header);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Loading Spinner */
.view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  gap: 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive Rules */
@media (max-width: 992px) {
  .app-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    z-index: 900;
    transform: translateX(-100%);
  }

  .app-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .app-content {
    padding: 1rem;
  }
}
