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

:root {
  --primary: #0b4c53;
  --primary-rgb: 11, 76, 83;
  --secondary: #2a7e8d;
  --secondary-rgb: 42, 126, 141;
  --highlight: #4bb2d4;
  --highlight-rgb: 75, 178, 212;
  --bg-dark: #f4f8f9;
  --bg-dark-rgb: 244, 248, 249;
  --card-bg: rgba(255, 255, 255, 0.75);
  --card-border: rgba(11, 76, 83, 0.12);
  --text-main: #0c323c;
  --text-muted: #507680;
  --glow-primary: rgba(11, 76, 83, 0.08);
  --glow-secondary: rgba(42, 126, 141, 0.08);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(var(--primary-rgb), 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(var(--secondary-rgb), 0.06) 0%, transparent 50%),
    linear-gradient(135deg, #f4f8f9 0%, #e2ecf0 100%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Glassmorphism Classes */
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.06);
}

.glass-hover:hover {
  border-color: rgba(var(--primary-rgb), 0.25);
  box-shadow: 0 8px 32px 0 rgba(var(--primary-rgb), 0.08);
  transform: translateY(-2px);
}

/* App Container */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* Login Screen Styles */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 950px;
  min-height: 550px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.login-info {
  background: linear-gradient(135deg, rgba(var(--secondary-rgb), 0.08) 0%, rgba(var(--primary-rgb), 0.03) 100%);
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--card-border);
  position: relative;
}

.login-info::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.03) 0%, transparent 60%);
  pointer-events: none;
}

.login-logo {
  max-height: 48px;
  object-fit: contain;
  align-self: flex-start;
}

.login-brand h2 {
  font-size: 2rem;
  color: var(--text-main);
  margin-bottom: 12px;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.login-servicios-img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.login-form-container {
  padding: 50px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-header h3 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  margin-bottom: 30px;
  font-size: 0.9rem;
}

.input-group {
  margin-bottom: 20px;
  position: relative;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-group input, .input-group select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

.input-group input:focus, .input-group select:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.1);
}

.btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #c86823 100%);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
  filter: brightness(1.1);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary) 0%, #1e5152 100%);
  box-shadow: 0 4px 15px rgba(var(--secondary-rgb), 0.3);
}

.btn-secondary:hover {
  box-shadow: 0 6px 20px rgba(var(--secondary-rgb), 0.4);
}

/* Dashboard Layout */
.sidebar {
  width: 260px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  z-index: 100;
  border-right: 1px solid var(--card-border);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.sidebar-logo {
  max-width: 150px;
  object-fit: contain;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  width: 100%;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  margin-top: 10px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: #fff;
  border: 2px solid var(--card-border);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

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

.menu-list {
  list-style: none;
  margin-top: 30px;
  flex-grow: 1;
}

.menu-item {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 0.95rem;
}

.menu-item:hover, .menu-item.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.menu-item.active {
  background: rgba(var(--primary-rgb), 0.15);
  border-left: 3px solid var(--primary);
  color: var(--text-main);
}

.main-content {
  flex-grow: 1;
  margin-left: 260px;
  padding: 40px;
  min-height: 100vh;
}

/* Page views transition wrapper */
.view-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Patient Dashboard Styles */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.header-row h1 {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.grid-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card {
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

/* Pain Scale Diary Styles */
.pain-selector {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pain-scale {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.015);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.pain-number-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.pain-number-btn:hover {
  transform: scale(1.1);
  background: rgba(15, 23, 42, 0.06);
}

/* Dynamic colors for pain rating selection */
.pain-0-2.selected { background-color: #10b981; box-shadow: 0 0 15px rgba(16, 185, 129, 0.2); border-color: #10b981; color: #fff; }
.pain-3-5.selected { background-color: #f59e0b; box-shadow: 0 0 15px rgba(245, 158, 11, 0.2); border-color: #f59e0b; color: #fff; }
.pain-6-8.selected { background-color: #f97316; box-shadow: 0 0 15px rgba(249, 115, 22, 0.2); border-color: #f97316; color: #fff; }
.pain-9-10.selected { background-color: #ef4444; box-shadow: 0 0 15px rgba(239, 68, 68, 0.2); border-color: #ef4444; color: #fff; }

.symptoms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.symptom-tag {
  padding: 10px;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  color: var(--text-main);
}

.symptom-tag.selected {
  background: rgba(var(--secondary-rgb), 0.12);
  border-color: var(--secondary);
  color: var(--secondary);
  font-weight: 600;
}

/* Care Team Cards */
.care-team-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-member-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.team-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(var(--secondary-rgb), 0.3) 0%, rgba(var(--primary-rgb), 0.2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.team-details h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.team-details p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-specialty {
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-block;
  margin-top: 4px;
}

/* Care Timeline (Domiciliary Schedule) */
.timeline {
  position: relative;
  padding-left: 24px;
  border-left: 2px solid rgba(255, 255, 255, 0.08);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -33px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 3px solid var(--secondary);
  box-shadow: 0 0 10px rgba(var(--secondary-rgb), 0.4);
}

.timeline-item.active::before {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.4);
}

.timeline-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-content {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.timeline-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.timeline-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.timeline-badge.scheduled { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.timeline-badge.transit { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.timeline-badge.completed { background: rgba(16, 185, 129, 0.15); color: #10b981; }

/* Doctor Dashboard Styles */
.patient-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.patient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: var(--transition);
}

.patient-row:hover, .patient-row.selected {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--secondary);
}

.patient-row.selected {
  box-shadow: 0 0 15px rgba(var(--secondary-rgb), 0.15);
}

.patient-basic-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.patient-name-block h4 {
  font-size: 1rem;
  margin-bottom: 2px;
}

.patient-name-block p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.patient-meta-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pain-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: 'Outfit', sans-serif;
  text-align: center;
  min-width: 60px;
}

.pain-badge.level-0-2 { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.pain-badge.level-3-5 { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.pain-badge.level-6-8 { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.pain-badge.level-9-10 { 
  background: rgba(239, 68, 68, 0.2); 
  color: #ef4444; 
  animation: pulse-danger 1.5s infinite alternate; 
}

@keyframes pulse-danger {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  100% { transform: scale(1.05); box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
}

/* Patient Clinic View (Detailed) */
.clinic-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.clinic-detail-header h3 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.tabs-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 10px;
}

.tab-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  border-radius: 6px;
}

.tab-btn:hover, .tab-btn.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Pain Chart / Analytics Placeholder style */
.chart-container {
  height: 220px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 24px 40px;
  position: relative;
}

.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 8px;
}

.chart-bar {
  width: 32px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(to top, var(--secondary) 0%, var(--primary) 100%);
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.1);
  position: relative;
}

.chart-bar::after {
  content: attr(data-val);
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
}

.chart-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Form Interdisciplinary Scheduler */
.schedule-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-col-full {
  grid-column: span 2;
}

.symptom-notes {
  margin-top: 15px;
  padding: 12px;
  background: rgba(var(--primary-rgb), 0.05);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

.notes-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 250px;
  overflow-y: auto;
}

.note-item {
  padding: 12px;
  background: rgba(15, 23, 42, 0.02);
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.note-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.note-text {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Dropdown selections styling */
select option {
  background: #ffffff;
  color: var(--text-main);
}

/* Floating Emergency Panel if any */
.emergency-alert-bar {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { border-color: rgba(239, 68, 68, 0.4); }
  50% { border-color: rgba(239, 68, 68, 0.85); }
  100% { border-color: rgba(239, 68, 68, 0.4); }
}

.alert-message {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #b91c1c;
  font-weight: 600;
}

.alert-icon {
  font-size: 1.25rem;
  animation: flash 1s infinite;
}

@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    padding: 16px;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .login-screen {
    padding: 16px;
  }
  
  .login-card {
    grid-template-columns: 1fr;
    min-height: auto;
    max-width: 440px;
    margin: 0 auto;
    border-radius: 16px;
  }
  
  .login-info {
    display: none; /* Hide brand sidebar on mobile login */
  }
  
  .login-form-container {
    padding: 30px 20px;
  }
  
  .login-header h3 {
    font-size: 1.4rem;
  }
  
  .login-header p {
    margin-bottom: 20px;
  }
  
  .pain-scale {
    padding: 8px;
    gap: 4px;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .pain-number-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.85rem;
  }
  
  .symptoms-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
  }
}

/* Admin Portal Specific Styles */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(11, 76, 83, 0.04);
}

.kpi-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: rgba(11, 76, 83, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.kpi-details {
  display: flex;
  flex-direction: column;
}

.kpi-value {
  font-size: 1.8rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Admin Table Styles */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 24px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: var(--card-bg);
}

.admin-table th {
  background: rgba(11, 76, 83, 0.05);
  color: var(--text-main);
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--card-border);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-main);
  font-size: 0.9rem;
}

.admin-table tbody tr:hover {
  background: rgba(11, 76, 83, 0.015);
}

.sla-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.sla-badge.good {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.sla-badge.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.sla-badge.critical {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Responsive Table cards on mobile */
@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
