/* ==========================================================================
   Apps Portal — Estilos Compartidos
   Portal: apps.axogenix-it.com
   Tipografía: Inter (Google Fonts)
   Iconos: Font Awesome 6.5+ (CDN)
   ========================================================================== */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- Font Awesome CDN (incluir en HTML) ---
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
*/

/* ==========================================================================
   1. CSS Custom Properties (Variables)
   ========================================================================== */

:root {
  /* Brand Colors — Portales Internos Axogenix */
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #1e40af;
  --secondary-hover: #1e3a8a;

  /* Text */
  --text-dark: #1f2937;
  --text-medium: #374151;
  --text-light: #6b7280;
  --text-muted: #9ca3af;

  /* Backgrounds */
  --white: #ffffff;
  --light-gray: #f9fafb;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;

  /* Borders */
  --border-color: #e5e7eb;
  --border-focus: #2563eb;

  /* Status Colors */
  --success-color: #059669;
  --success-bg: #ecfdf5;
  --warning-color: #d97706;
  --warning-bg: #fffbeb;
  --danger-color: #dc2626;
  --danger-bg: #fef2f2;
  --info-color: #2563eb;
  --info-bg: #eff6ff;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* Layout */
  --max-width: 1200px;
  --header-height: 64px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ==========================================================================
   2. CSS Reset / Base Styles
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dark);
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dark);
}

/* ==========================================================================
   3. Typography
   ========================================================================== */

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ==========================================================================
   4. Layout
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: var(--spacing-xl) 0;
}

/* ==========================================================================
   5. Header Component
   ========================================================================== */

.header {
  background: var(--white);
  box-shadow: var(--shadow-md);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.header-logo img {
  height: 36px;
  width: auto;
}

.header-logo span {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-dark);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.header-nav a {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.header-nav a:hover {
  color: var(--primary-color);
  background: var(--gray-50);
  text-decoration: none;
}

.header-nav a.active {
  color: var(--primary-color);
  background: var(--info-bg);
  font-weight: 600;
}

.header-user {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.header-user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-dark);
}

.header-user-role {
  font-size: 0.75rem;
  color: var(--text-light);
}

.header-logout {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.header-logout:hover {
  color: var(--danger-color);
  background: var(--danger-bg);
  text-decoration: none;
}

/* ==========================================================================
   6. Footer Component
   ========================================================================== */

.footer {
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-lg) 0;
  text-align: center;
  background: var(--white);
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ==========================================================================
   7. Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--white);
}

.btn-secondary {
  background: var(--white);
  color: var(--text-dark);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--text-light);
  color: var(--text-dark);
}

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

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
  color: var(--white);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   8. Forms
   ========================================================================== */

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-medium);
  margin-bottom: var(--spacing-xs);
}

.form-label .required {
  color: var(--danger-color);
  margin-left: 2px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-dark);
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:disabled {
  background: var(--gray-100);
  cursor: not-allowed;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-text {
  display: block;
  margin-top: var(--spacing-xs);
  font-size: 0.75rem;
  color: var(--text-light);
}

.form-error {
  display: block;
  margin-top: var(--spacing-xs);
  font-size: 0.75rem;
  color: var(--danger-color);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

/* ==========================================================================
   9. Cards / Panels
   ========================================================================== */

.card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.card-header h2,
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: var(--spacing-lg);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--gray-50);
}

.panel {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xl);
}

/* ==========================================================================
   10. Error Messages / Toasts / Alerts
   ========================================================================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
}

.alert-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-content {
  flex: 1;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-color);
  border: 1px solid #a7f3d0;
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-color);
  border: 1px solid #fde68a;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-color);
  border: 1px solid #fecaca;
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-color);
  border: 1px solid #bfdbfe;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--spacing-md));
  right: var(--spacing-md);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary-color);
  animation: toast-slide-in var(--transition-slow) ease;
}

.toast-success { border-left-color: var(--success-color); }
.toast-warning { border-left-color: var(--warning-color); }
.toast-error { border-left-color: var(--danger-color); }

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-dark);
}

.toast-close {
  color: var(--text-light);
  font-size: 1.125rem;
  padding: var(--spacing-xs);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-dark);
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==========================================================================
   11. Loading Spinner
   ========================================================================== */

.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

.spinner-lg {
  width: 2.5rem;
  height: 2.5rem;
  border-width: 4px;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  padding: var(--spacing-2xl);
  color: var(--text-light);
  font-size: 0.875rem;
}

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

/* ==========================================================================
   12. Responsive Breakpoints (Mobile-First)
   ========================================================================== */

/* Small devices (phones, up to 640px) */
@media (max-width: 640px) {
  :root {
    --header-height: 56px;
  }

  .container {
    padding: 0 var(--spacing-md);
  }

  .header-nav {
    display: none;
  }

  .header-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-md);
    z-index: 99;
  }

  .header-user-info {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}

/* Medium devices (tablets, 641px to 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  .container {
    padding: 0 var(--spacing-lg);
  }
}

/* Large devices (desktops, 1025px+) */
@media (min-width: 1025px) {
  .container {
    padding: 0 var(--spacing-xl);
  }
}

/* ==========================================================================
   13. Utility Classes
   ========================================================================== */

/* Display */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }

/* Flexbox */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Gap */
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }

/* Text alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Text colors */
.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-dark { color: var(--text-dark); }
.text-light { color: var(--text-light); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }

/* Spacing */
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

/* Width */
.w-full { width: 100%; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Visibility (accessible hidden) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Truncate text */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
