/* ============================================================================
   APX CONNECT - Login Styles
   Sistema de Expediente Clínico Prehospitalario
   ============================================================================ */

/* --------------------------------------------------------------------------
   CSS Variables / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --apx-primary: #0369a1;
  --apx-primary-dark: #075985;
  --apx-primary-light: #0ea5e9;
  --apx-accent: #06b6d4;
  
  /* Neutral Palette */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;
  
  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Shadows */
  --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-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.6;
  color: var(--slate-800);
  background: var(--slate-100);
}

/* --------------------------------------------------------------------------
   Login Body
   -------------------------------------------------------------------------- */
.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: 
    linear-gradient(135deg, var(--slate-900) 0%, var(--slate-800) 100%);
  position: relative;
  overflow: hidden;
}

/* Animated background pattern */
.login-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(6, 182, 212, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(3, 105, 161, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 40% 80%, rgba(14, 165, 233, 0.1) 0%, transparent 50%);
  animation: pulseBackground 15s ease-in-out infinite alternate;
}

@keyframes pulseBackground {
  0% { opacity: 0.5; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.1); }
}

/* Grid pattern overlay */
.login-body::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Login Container
   -------------------------------------------------------------------------- */
.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: 1000px;
  min-height: 580px;
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   Brand Section (Left Panel)
   -------------------------------------------------------------------------- */
.brand-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: 
    linear-gradient(135deg, var(--apx-primary-dark) 0%, var(--apx-primary) 50%, var(--apx-accent) 100%);
  position: relative;
  overflow: hidden;
}

/* Decorative circles */
.brand-section::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  top: -100px;
  right: -100px;
}

.brand-section::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 50%;
  bottom: -80px;
  left: -80px;
}

.brand-section img {
  position: relative;
  z-index: 1;
  max-width: 220px;
  height: auto;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.3));
  animation: floatLogo 6s ease-in-out infinite;
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.brand-section h3 {
  position: relative;
  z-index: 1;
  margin-top: 2rem;
  font-size: 1.125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  letter-spacing: 0.025em;
}

/* Protected media - prevent copying/saving */
.protected-media {
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.protected-media.shield::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
}

/* --------------------------------------------------------------------------
   Login Section (Right Panel)
   -------------------------------------------------------------------------- */
.login-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem;
  background: white;
}

.login-header {
  margin-bottom: 2.5rem;
  text-align: center;
}

.login-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--slate-800);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.login-header h2 i {
  color: var(--apx-primary);
  font-size: 1.5rem;
}

.login-header p {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: var(--slate-500);
}

/* --------------------------------------------------------------------------
   Form Styles
   -------------------------------------------------------------------------- */
#loginForm {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
}

/* Input Group */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--slate-50);
  border: 2px solid var(--slate-200);
  border-radius: var(--radius-lg);
  transition: 
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    background-color var(--transition-base);
}

.input-group:hover {
  border-color: var(--slate-300);
}

.input-group:focus-within {
  border-color: var(--apx-primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(3, 105, 161, 0.1);
}

.input-group label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  color: var(--slate-400);
  font-size: 1.125rem;
  transition: color var(--transition-base);
  flex-shrink: 0;
}

.input-group:focus-within label {
  color: var(--apx-primary);
}

.input-group input {
  flex: 1;
  height: 3.25rem;
  padding: 0 1rem 0 0;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--slate-800);
  outline: none;
}

.input-group input::placeholder {
  color: var(--slate-400);
}

/* Toggle Password Button */
.toggle-pass {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3.25rem;
  background: transparent;
  border: none;
  color: var(--slate-400);
  cursor: pointer;
  transition: color var(--transition-base);
  flex-shrink: 0;
}

.toggle-pass:hover {
  color: var(--apx-primary);
}

.toggle-pass[aria-pressed="true"] {
  color: var(--apx-primary);
}

/* --------------------------------------------------------------------------
   Login Button
   -------------------------------------------------------------------------- */
.btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  height: 3.25rem;
  margin-top: 0.75rem;
  padding: 0 1.5rem;
  background: linear-gradient(135deg, var(--apx-primary) 0%, var(--apx-primary-dark) 100%);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: 
    transform var(--transition-fast),
    box-shadow var(--transition-base),
    background var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--apx-primary-light) 0%, var(--apx-primary) 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.btn-login:hover::before {
  opacity: 1;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(3, 105, 161, 0.4);
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px -2px rgba(3, 105, 161, 0.3);
}

.btn-login i,
.btn-login span {
  position: relative;
  z-index: 1;
}

/* Loading State */
.btn-login.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn-login.loading i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Message Display
   -------------------------------------------------------------------------- */
.login-msg {
  min-height: 1.5rem;
  margin-top: 0.5rem;
  padding: 0;
  font-size: 0.875rem;
  text-align: center;
  transition: all var(--transition-base);
}

.login-msg:empty {
  display: none;
}

.login-msg.error {
  display: block;
  padding: 0.875rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: var(--error);
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.login-msg.success {
  display: block;
  padding: 0.875rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  color: var(--success);
}

.login-msg.info {
  display: block;
  padding: 0.875rem 1rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  color: var(--info);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* --------------------------------------------------------------------------
   Input Validation States
   -------------------------------------------------------------------------- */
.input-group.error {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.05);
}

.input-group.error label {
  color: var(--error);
}

.input-group.success {
  border-color: var(--success);
}

.input-group.success label {
  color: var(--success);
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .login-container {
    flex-direction: column;
    max-width: 420px;
    min-height: auto;
  }
  
  .brand-section {
    padding: 2.5rem 2rem;
    min-height: auto;
  }
  
  .brand-section img {
    max-width: 160px;
  }
  
  .brand-section h3 {
    font-size: 1rem;
    margin-top: 1.5rem;
  }
  
  .login-section {
    padding: 2.5rem 2rem;
  }
  
  .login-header {
    margin-bottom: 2rem;
  }
  
  .login-header h2 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .login-body {
    padding: 0;
    align-items: stretch;
  }
  
  .login-container {
    border-radius: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }
  
  .brand-section {
    padding: 2rem 1.5rem;
    border-radius: 0;
  }
  
  .login-section {
    padding: 2rem 1.5rem;
    flex: 1;
  }
  
  .login-header h2 {
    font-size: 1.375rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  #loginForm {
    gap: 1rem;
  }
  
  .input-group,
  .btn-login {
    height: 3rem;
  }
  
  .input-group label {
    width: 3rem;
    height: 3rem;
  }
}

/* --------------------------------------------------------------------------
   High Contrast / Accessibility
   -------------------------------------------------------------------------- */
@media (prefers-contrast: high) {
  .input-group {
    border-width: 3px;
  }
  
  .btn-login {
    border: 2px solid white;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   Focus Visible (Keyboard Navigation)
   -------------------------------------------------------------------------- */
.input-group:has(input:focus-visible) {
  outline: 2px solid var(--apx-primary);
  outline-offset: 2px;
}

.btn-login:focus-visible,
.toggle-pass:focus-visible {
  outline: 2px solid var(--apx-primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Print Styles
   -------------------------------------------------------------------------- */
@media print {
  .login-body {
    background: white;
  }
  
  .brand-section {
    display: none;
  }
}