/* FailSafe — Emergency Access Vault */
/* Warm, friendly design to counter morbid topic */

:root {
  /* Warm, reassuring colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  /* Warm neutrals */
  --bg-main: #faf9f7;
  --bg-card: #ffffff;
  --bg-sidebar: #1e1b4b;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* 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);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: white;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-2xl);
}

.logo-icon {
  font-size: 2rem;
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  margin-bottom: var(--space-xs);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(255, 255, 255, 0.7);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-icon {
  font-size: 1.2rem;
}

.sidebar-footer {
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

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

.user-name {
  font-weight: 600;
}

.user-plan {
  font-size: 0.75rem;
  color: var(--secondary);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: var(--space-xl);
  max-width: 1200px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  margin-bottom: var(--space-xl);
}

.view-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.subtitle {
  color: var(--text-secondary);
}

/* Check-in Banner */
.checkin-banner {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-lg);
}

.checkin-status {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.status-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.status-icon.success {
  background: rgba(255, 255, 255, 0.2);
}

.status-info h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-xs);
}

.status-info p {
  opacity: 0.9;
}

/* Buttons */
.btn {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.875rem;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-main);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.stat-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Health Section */
.health-section {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
  border: 1px solid var(--border);
}

.health-section h2 {
  margin-bottom: var(--space-md);
  font-size: 1.125rem;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.health-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
}

.health-item.good {
  background: #ecfdf5;
  color: #065f46;
}

.health-item.warning {
  background: #fef3c7;
  color: #92400e;
}

.health-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
}

.health-item.good .health-icon {
  background: var(--success);
  color: white;
}

.health-item.warning .health-icon {
  background: var(--warning);
  color: white;
}

/* Activity Section */
.activity-section {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.activity-section h2 {
  margin-bottom: var(--space-md);
  font-size: 1.125rem;
}

.activity-list {
  list-style: none;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.activity-text {
  flex: 1;
}

.activity-time {
  color: var(--text-light);
  font-size: 0.875rem;
}

/* Vault View */
.vault-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.search-box input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 250px;
}

.vault-categories {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.category-btn {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
}

.category-btn:hover,
.category-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.vault-item {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.vault-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.vault-item-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.vault-item-icon {
  width: 48px;
  height: 48px;
  background: #f3f4f6;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.vault-item-title {
  font-weight: 600;
}

.vault-item-category {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.vault-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-light);
}

.access-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
}

.access-badge.emergency {
  background: #fef2f2;
  color: var(--danger);
}

.access-badge.inner {
  background: #faf5ff;
  color: #7c3aed;
}

.access-badge.executor {
  background: #f0f9ff;
  color: #0369a1;
}

/* Contacts View */
.contacts-info {
  margin-bottom: var(--space-lg);
}

.info-card {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
}

.info-card.warm {
  background: #fef3c7;
  border-color: #fcd34d;
}

.info-card h3 {
  margin-bottom: var(--space-sm);
}

.info-card p {
  color: var(--text-secondary);
}

.contacts-actions {
  margin-bottom: var(--space-lg);
}

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.contact-card {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.contact-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.contact-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.25rem;
  color: white;
}

.contact-info h3 {
  font-size: 1.125rem;
}

.contact-info p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.contact-tier {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: #f3f4f6;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.contact-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-light);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.status-dot.active {
  background: var(--success);
}

.status-dot.pending {
  background: var(--warning);
}

/* Access Tiers */
.access-tiers h2 {
  margin-bottom: var(--space-md);
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.tier-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.tier-header {
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.tier-header.emergency {
  background: #fef2f2;
}

.tier-header.inner {
  background: #faf5ff;
}

.tier-header.executor {
  background: #f0f9ff;
}

.tier-card p {
  padding: var(--space-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Messages View */
.messages-intro {
  margin-bottom: var(--space-lg);
}

.messages-actions {
  margin-bottom: var(--space-lg);
}

.messages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.message-card {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: var(--space-md);
}

.message-recipient {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.message-type {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: var(--radius-full);
}

.message-preview {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
}

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

/* Settings View */
.settings-section {
  background: var(--bg-card);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

.settings-section h2 {
  font-size: 1.125rem;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.settings-section.danger-zone {
  border-color: #fecaca;
}

.settings-section.danger-zone h2 {
  color: var(--danger);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-info h3 {
  font-size: 0.875rem;
  font-weight: 600;
}

.setting-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.setting-select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 48px;
  height: 24px;
  display: inline-block;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #d1d5db;
  border-radius: var(--radius-full);
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: var(--radius-full);
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

.modal h2 {
  margin-bottom: var(--space-lg);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

/* Toast */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  background: var(--success);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.active {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .tier-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: var(--space-md);
  }
  
  .nav-links {
    display: flex;
    overflow-x: auto;
  }
  
  .nav-item span:not(.nav-icon) {
    display: none;
  }
  
  .sidebar-footer {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
    padding: var(--space-md);
  }
  
  .app {
    flex-direction: column;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .checkin-banner {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
  
  .health-grid {
    grid-template-columns: 1fr;
  }
}
