/* Sidebar styling */
:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 60px;
  --transition-speed: 0.3s;

  /* Autora Color Scheme */
  --dw-primary: #2196F3;      /* Azul principal, similar al logo */
  --dw-primary-dark: #1976D2;
  --dw-primary-darker: #0D47A1;
  --dw-primary-light: #64B5F6;
  --dw-primary-lighter: #BBDEFB;
  --dw-accent: #E3F2FD;

  /* Pastel Theme Colors for Light Mode */
  --pastel-green: #a8e6cf;
  --pastel-green-light: #dcedc1;
  --pastel-blue: #a8e6e6;
  --pastel-blue-light: #d1e8e8;
  --pastel-blue-dark: #61c0bf;
  --pastel-accent: #ffd3b6;
}

/* Light Mode Overrides */
[data-bs-theme="light"] {
  --bs-body-bg: #ffffff;
  --bs-body-color: #343a40;
  --bs-border-color: #dee2e6;

  /* Sidebar Light Theme */

/* Estilos para vista previa de documento a altura completa */
.vh-100 {
    height: 100vh !important;
    margin-bottom: 0 !important;
}

.sticky-top {
    position: sticky;
    top: 1rem;
}

/* Modal extra grande personalizado para el editor de plantillas */
.modal-template-xl .modal-dialog {
    max-width: 98% !important;
    width: 98% !important;
    margin: 1.75rem auto;
}

/* Profile avatar styles - compact version */
.profile-avatar-small {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #e9ecef;
    background: #f8f9fa;
    position: relative;
}

.profile-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-avatar-placeholder-small {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 50%;
}

/* Vista previa mejorada para el editor de plantillas */
#template_preview_container iframe {
    transform: scale(2.2) !important;
    transform-origin: top left !important;
}

/* Ajustar área de formulario y vista previa para más espacio */
#editTemplateModal .modal-body .col-md-6:first-child {
    flex: 0 0 auto;
    width: 40%;
}

#editTemplateModal .modal-body .col-md-6:last-child {
    flex: 0 0 auto;
    width: 60%;
}

/* Ajustes para el contenedor del iframe */
.document-preview {
    height: calc(100vh - 120px) !important;
    min-height: unset !important;
}

.document-preview iframe {
    height: 100% !important;
    min-height: unset !important;
}

/* Footer siempre visible y por encima */
.footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: var(--navbar-bg);
    z-index: 1050;
    padding: 10px 0;
}

/* Ajustar contenido principal para evitar superposición con footer */
#content {
    padding-bottom: 60px;
    min-height: calc(100vh - 60px);
}

/* Contenedor del documento con margen inferior */
.document-preview-container {
    margin-bottom: 60px;
}


.btn.processing {
    position: relative;
    cursor: not-allowed;
    opacity: 0.8;
}

.btn.processing .fa-spin {
    display: inline-block;
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

  --sidebar-bg: #ffffff;
  --sidebar-color: #2c3e50;
  --sidebar-hover-bg: rgba(3, 172, 19, 0.05);
  --sidebar-active-bg: var(--dw-primary);
  --sidebar-header-bg: var(--dw-primary);
  --sidebar-header-color: #fff;

  /* Navbar Light Theme */
  --navbar-bg: var(--dw-primary);
  --navbar-color: #fff;

  /* Card Light Theme */
  --card-bg: #ffffff;
  --card-border: #e9ecef;
  --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);

  /* Button Light Theme */
  --btn-primary-bg: var(--dw-primary);
  --btn-primary-border: var(--dw-primary-dark);
}

/* Tarjetas de plantilla en modo claro */
[data-bs-theme="light"] .template-card {
  background-color: #fff;
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05) !important;
}

[data-bs-theme="light"] .template-card:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

[data-bs-theme="light"] .template-card .card-header {
  background-color: rgba(3, 172, 19, 0.1);
  color: #2c3e50;
  border-bottom: 1px solid var(--bs-border-color);
}

[data-bs-theme="light"] .user-profile {
  background-color: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

[data-bs-theme="light"] .profile-link {
  color: #343a40 !important;
}

[data-bs-theme="light"] .profile-link:hover {
  background-color: rgba(33, 150, 243, 0.1);
  color: #343a40 !important;
}

[data-bs-theme="light"] .profile-company {
  color: rgba(0, 0, 0, 0.7);
}

/* Dark Mode Colors (Default) */
[data-bs-theme="dark"] {
  --sidebar-bg: var(--bs-dark);
  --sidebar-color: #fff;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
  --sidebar-active-bg: var(--dw-primary);
  --sidebar-header-bg: var(--dw-primary);
  --sidebar-header-color: #fff;

  --navbar-bg: var(--dw-primary);
  --navbar-color: #fff;

  --card-bg: var(--bs-dark-bg-subtle);
  --card-border: rgba(255, 255, 255, 0.1);
  --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.15);

  --btn-primary-bg: var(--dw-primary);
  --btn-primary-border: var(--dw-primary-dark);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

.wrapper {
  display: flex;
  width: 100%;
  align-items: stretch;
}

#sidebar {
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-color);
  transition: all var(--transition-speed);
  z-index: 1000;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
}

#sidebar.collapsed {
  min-width: var(--sidebar-collapsed-width);
  max-width: var(--sidebar-collapsed-width);
}

#sidebar .sidebar-header {
  padding: 0;
  cursor: pointer;
  background: var(--sidebar-header-bg);
}

#sidebar .sidebar-header a {
  padding: 0;
  display: flex;
  align-items: center;
  color: var(--sidebar-header-color);
  text-decoration: none;
  transition: all var(--transition-speed);
}

#sidebar .sidebar-header:hover {
  background: var(--sidebar-hover-bg);
}

#sidebar .sidebar-header i {
  min-width: 30px;
  text-align: center;
  font-size: 1.1rem;
}

#sidebar .sidebar-header span {
  margin-left: 10px;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--sidebar-header-color);
}

#sidebar.collapsed .sidebar-header span {
  display: none;
}

#sidebar ul.components {
  padding: 20px 0;
  border-bottom: 1px solid var(--bs-border-color);
}

#sidebar ul li a {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  color: var(--sidebar-color);
  text-decoration: none;
  transition: all var(--transition-speed);
}

#sidebar ul li a:hover {
  color: var(--sidebar-color);
  background: var(--sidebar-hover-bg);
}

#sidebar ul li a.active {
  color: white;
  background: var(--sidebar-active-bg);
}

#sidebar ul li a i {
  min-width: 30px;
  text-align: center;
  font-size: 1.1rem;
}

#sidebar ul li a span {
  margin-left: 10px;
  transition: all var(--transition-speed);
}

#sidebar.collapsed ul li a span {
  display: none;
}

/* Estilos para los submenús del sidebar */
#sidebar ul ul {
  padding-left: 0;
  background-color: rgba(0, 0, 0, 0.05);
  border-left: 3px solid var(--dw-primary);
  margin-left: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease-in-out;
}

#sidebar ul ul.show {
  max-height: 1000px;
}

#sidebar ul ul li a {
  padding: 10px 10px 10px 55px;
  font-size: 0.9rem;
}

#sidebar ul ul li a i {
  font-size: 0.9rem;
}

#sidebar ul ul li a.active {
  background-color: rgba(33, 150, 243, 0.3);
}

#sidebar ul li a.dropdown-toggle {
  position: relative;
}

#sidebar ul li a.dropdown-toggle::after {
  content: '\f107';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  position: absolute;
  right: 20px;
  transition: transform 0.3s;
}

#sidebar ul li a.dropdown-toggle[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

#sidebar.collapsed ul li a.dropdown-toggle::after {
  display: none;
}

#content {
  width: 100%;
  min-height: 100vh;
  transition: all var(--transition-speed);
  margin-left: var(--sidebar-width);
}

/* Mantener consistencia en las vistas AJAX */
#content-wrapper .container-fluid {
  padding: inherit;
}

#content.expanded {
  margin-left: var(--sidebar-collapsed-width);
}

.navbar {
  padding: 0 10px;
  background: var(--navbar-bg);
  border: none;
  border-radius: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

.navbar-btn {
  box-shadow: none;
  outline: none !important;
  border: none;
}

.menu-btn {
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--navbar-color);
  padding: 5px 10px;
  font-size: 1.2rem;
}

.menu-btn:focus {
  outline: none;
}

.brand-logo {
  font-size: 1.5rem;
  font-weight: 600;
}

/* Título de página en navbar */
.page-title {
  font-size: 1.25rem;
  font-weight: 500;
  margin-left: 10px;
  letter-spacing: 0.5px;
  text-transform: capitalize;
  display: flex;
  align-items: center;
}

.page-title i {
  margin-right: 8px;
  font-size: 1rem;
}

/* Mobile Styles */
@media (max-width: 768px) {
  #sidebar {
    min-width: 0;
    max-width: 0;
    opacity: 0;
    transform: translateX(-100%);
    height: calc(100vh - var(--topbar-height));
    top: var(--topbar-height);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1030;
  }

  #sidebar.active {
    min-width: 85%;
    max-width: 300px;
    opacity: 1;
    transform: translateX(0);
  }

  #content {
    margin-left: 0;
  }

  #content.expanded {
    margin-left: 0;
  }

  .navbar {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 999;
  }

  .content-wrapper {
    padding-top: calc(var(--topbar-height) + 20px);
  }

  /* Garantizar que el contenido tenga los márgenes correctos en ajax */
  #content-wrapper {
    padding-top: var(--topbar-height) !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }

  .overlay {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--topbar-height));
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: all 0.5s ease-in-out;
    z-index: 1020;
  }

  .overlay.active {
    display: block;
    opacity: 1;
  }

  /* Hamburger button styles */
  .navbar-toggler {
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    background-color: transparent;
    border: 1px solid var(--dw-primary);
    border-radius: 0.25rem;
    margin-right: 10px;
    color: var(--dw-primary);
  }

  .navbar-toggler:focus {
    outline: none;
    box-shadow: 0 0 0 0.25rem rgba(3, 172, 19, 0.25);
  }

  .navbar-brand {
    margin-right: 0;
    color: white;
    font-weight: 600;
  }

  /* Mobile profile styles */
  .user-mobile-profile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
  }

  .mobile-profile-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-profile-icon img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
  }

  .mobile-profile-icon i {
    font-size: 1.5rem;
    color: var(--dw-primary);
  }

  .dropdown-header {
    font-weight: 600;
    color: var(--bs-body-color);
    padding: 0.5rem 1rem;
    margin-bottom: 0;
  }

  .dropdown-text {
    display: block;
    margin-bottom: 0.5rem;
  }

  .dropdown-menu {
    background-color: var(--card-bg);
    border: 1px solid var(--bs-border-color);
  }

  .dropdown-item {
    color: var(--bs-body-color);
  }

  .dropdown-item:hover, 
  .dropdown-item:focus {
    background-color: var(--sidebar-hover-bg);
    color: var(--bs-body-color);
  }

  /* Ocultar el perfil en el sidebar solo en dispositivos móviles */
  #sidebar .user-profile {
    display: none;
  }
}

/* Template card styling */
.template-card {
  transition: all 0.3s;
}

.template-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2) !important;
}

.template-thumbnail {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer adjustments */
.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background-color: var(--navbar-bg);
  z-index: 900;
}

/* Add bottom padding to content to prevent footer overlap */
#content {
  padding-bottom: 60px;
}

/* Login page styling */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  background-color: var(--bs-dark-bg-subtle);
  background-image: linear-gradient(135deg, rgba(35, 35, 50, 0.8) 0%, rgba(20, 20, 40, 0.9) 100%);
  background-size: cover;
}

.login-logo {
  max-width: 80px;
  margin-bottom: 20px;
}

.login-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 15px 30px rgba(0,0,0,0.3);
  border: none;
}

.login-header {
  padding: 25px 0;
  background: linear-gradient(90deg, var(--dw-primary) 0%, var(--dw-primary-darker) 100%);
}

.login-footer {
  margin-top: 30px;
  padding: 15px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.login-page .display-4 {
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  margin-bottom: 5px;
  color: var(--dw-primary) !important;
}

.login-page .lead {
  color: rgba(0, 0, 0, 0.7);
  margin-bottom: 30px;
}

.login-page .btn-primary,
.login-page .btn-success {
  background: linear-gradient(90deg, var(--dw-primary) 0%, var(--dw-primary-dark) 100%);
  border: none;
  padding: 12px;
  transition: all 0.3s;
}

.login-page .btn-primary:hover,
.login-page .btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* User Profile in Sidebar */
.user-profile {
  position: absolute;
  bottom: 60px;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: block;
  z-index: 1020;
}

.user-profile .dropdown-menu {
  min-width: 200px;
  margin-top: 0;
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
  background-color: var(--bs-body-bg);
  position: absolute;
  top: auto;
  bottom: 100%;
  right: 0;
  left: auto;
  z-index: 1021;
}

.user-profile .dropdown-item {
  padding: 0.5rem 1rem;
  color: var(--bs-body-color);
}

.user-profile .dropdown-item:hover {
  background-color: var(--sidebar-hover-bg);
}

.profile-link {
  padding: 15px;
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.8) !important;
  text-decoration: none;
  transition: all var(--transition-speed);
}

.profile-link:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.05);
}

.profile-image {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--dw-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-right: 12px;
}

.profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-icon {
  font-size: 1.2rem;
  color: white;
}

.profile-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.profile-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-company {
  font-size: 0.75rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-icon {
  margin-left: 5px;
  display: flex;
  align-items: center;
}

.dropdown-icon i {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
}

.user-profile .dropdown-menu {
  margin-top: 0;
  margin-bottom: 10px;
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.user-profile .dropdown-item {
  padding: 8px 16px;
  color: var(--bs-body-color);
}

.user-profile .dropdown-item:hover {
  background-color: var(--bs-light);
}
}

/* Collapsed Sidebar Profile Adjustments */
#sidebar.collapsed .user-profile {
  width: var(--sidebar-collapsed-width);
}

#sidebar.collapsed .user-profile .profile-info,
#sidebar.collapsed .user-profile .dropdown-icon {
  display: none;
}

#sidebar.collapsed .profile-image {
  margin-right: 0;
  margin-left: auto;
  margin-right: auto;
}

/* Admin section styling */
.admin-section {
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  margin-top: 10px;
  padding-top: 10px;
}

.admin-section a {
  background-color: rgba(255, 255, 255, 0.05);
}

.admin-section a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* File input styling */
[data-bs-theme="light"] .form-control[type="file"] {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  color: #212529;
}

[data-bs-theme="light"] .form-control[type="file"]::-webkit-file-upload-button {
  background-color: #e9ecef;
  color: #212529;
  border: 1px solid #dee2e6;
}

/* Estilos mejorados para los menús desplegables */
.dropdown-menu {
  padding: 0.5rem 0;
  border-radius: 8px;
  border: 0;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
  animation: fadeInMenu 0.2s ease-in-out;
}

.dropdown-item {
  padding: 0.6rem 1rem;
  transition: all 0.2s;
  border-radius: 4px;
  margin: 0 0.25rem;
  width: calc(100% - 0.5rem);
}

.dropdown-item:hover {
  background-color: rgba(33, 150, 243, 0.1);
}

.dropdown-item i {
  width: 20px;
  text-align: center;
  margin-right: 8px;
  color: var(--dw-primary);
}

.dropdown-divider {
  margin: 0.3rem 0;
}

.btn.dropdown-toggle {
  display: flex;
  align-items: center;
}

.dropdown-toggle::after {
  margin-left: 0.5em;
  vertical-align: middle;
  transition: transform 0.2s;
}

.dropdown.show .dropdown-toggle::after {
  transform: rotate(180deg);
}

@keyframes fadeInMenu {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* DocuWare Config Styling */
.auth-fields {
  border-left: 3px solid var(--dw-primary);
  padding-left: 15px;
  margin-bottom: 20px;
  background-color: rgba(3, 172, 19, 0.05);
  padding: 15px;
  border-radius: 5px;
}

.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 5px;
  border-radius: 4px;
}
/* Autora Rebranding - Auth Pages */
[data-bs-theme="light"] .btn-primary,
[data-bs-theme="light"] .btn-success {
  background-color: var(--dw-primary) !important;
  border-color: var(--dw-primary-dark) !important;
}

[data-bs-theme="light"] .btn-primary:hover,
[data-bs-theme="light"] .btn-success:hover {
  background-color: var(--dw-primary-dark) !important;
  border-color: var(--dw-primary-darker) !important;
}

.auth-logo {
  max-width: 150px;
  margin-bottom: 10px;
}

.login-page h2,
.register-page h2 {
  color: var(--dw-primary) !important;
}

.login-header,
.register-header {
  background-color: var(--dw-primary) !important;
}

/* Prevenir el cambio de color en hover del logo */
.logo-image:hover, a:hover .logo-image, 
.sidebar-header:hover .logo-image, 
.sidebar-header:hover span, 
.logo-wrapper:hover * {
  opacity: 1 !important;
  filter: none !important;
  color: inherit !important;
}

/* Ajustes para el visor de PDF */
.document-preview object {
  width: 100%;
  height: 100%;
  display: block;
}

/* Estilos para la vista de documento */
.document-preview-container {
  border-radius: 0.25rem;
  overflow: hidden;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  background-color: var(--bs-gray-100);
  height: 100%;
}

.document-info-panel {
  border-right: 1px solid var(--bs-border-color);
  height: 100%;
}

.navbar .dropdown-menu {
  background-color: var(--bs-body-bg);
  border: none;
  border-radius: 10px;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
  margin-top: 0.5rem;
  padding: 0.8rem 0;
  animation: dropdownAnimation 0.3s ease-in-out forwards;
  transform-origin: top right;
}

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

.navbar .dropdown-item {
  color: var(--bs-body-color);
  padding: 0.6rem 1.2rem;
  margin: 0.2rem 0.6rem;
  border-radius: 6px;
  transition: all 0.2s ease-in-out;
  font-weight: 500;
}

.navbar .dropdown-item:hover, 
.navbar .dropdown-item:focus {
  background-color: rgba(33, 150, 243, 0.1);
  color: var(--dw-primary);
  transform: translateX(5px);
}

.navbar .dropdown-divider {
  border-top-color: rgba(0, 0, 0, 0.1);
  margin: 0.5rem 0.8rem;
}

/* Estilo para los botones de dropdown en la barra superior */
.navbar .btn-outline-light.dropdown-toggle {
  display: flex;
  align-items: center;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.navbar .btn-outline-light.dropdown-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.navbar .dropdown-toggle::after {
  transition: transform 0.2s ease;
  margin-left: 0.4rem;
}

.navbar .dropdown.show .dropdown-toggle::after {
  transform: rotate(180deg);
}