/**
 * Medical Document Management System - Main Stylesheet
 * Version: 1.0
 * Design: Friendly "Cuqui" Style
 *
 * Based on the style guide at: application/cuqui-prototype/style-guide.md
 */

/* ============================================================================
   CSS Variables - Root Configuration
   ========================================================================= */

:root {
  /* Primary Colors - Sky Blue Family */
  --color-sky-50: #E3F2FD;
  --color-sky-100: #BBDEFB;
  --color-sky-300: #90CAF9;
  --color-sky-400: #81D4FA;
  --color-sky-500: #64B5F6;
  --color-sky-600: #42A5F5;
  --color-sky-700: #1976D2;
  --color-sky-800: #1565C0;

  /* Status Colors */
  --color-success: #66BB6A;
  --color-success-light: #81C784;
  --color-success-dark: #4CAF50;

  --color-warning: #FFCA28;
  --color-warning-light: #FFD54F;
  --color-warning-dark: #FFC107;

  --color-error: #EF5350;
  --color-error-light: #E57373;
  --color-error-dark: #E53935;

  /* Neutral Colors */
  --color-white: #FFFFFF;
  --color-gray-50: #FAFAFA;
  --color-gray-100: #F5F5F5;
  --color-gray-200: #EEEEEE;
  --color-gray-300: #E0E0E0;
  --color-gray-400: #BDBDBD;
  --color-gray-500: #9E9E9E;
  --color-gray-600: #757575;
  --color-gray-700: #616161;
  --color-gray-800: #424242;
  --color-gray-900: #212121;

  /* Primary Shortcuts */
  --color-primary: #42A5F5;
  --color-primary-light: #64B5F6;
  --color-primary-dark: #1976D2;

  /* Typography */
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

  --font-h1-size: 20px;
  --font-h1-weight: 600;

  --font-h2-size: 24px;
  --font-h2-weight: 600;

  --font-h3-size: 18px;
  --font-h3-weight: 600;

  --font-h4-size: 16px;
  --font-h4-weight: 600;

  --font-body-size: 14px;
  --font-body-weight: 400;

  --font-body-bold-size: 14px;
  --font-body-bold-weight: 600;

  --font-small-size: 12px;
  --font-small-weight: 400;

  --font-tiny-size: 11px;
  --font-tiny-weight: 400;

  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.8;

  /* Spacing System (4px base unit) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 15px;
  --radius-xl: 20px;
  --radius-pill: 25px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 4px 12px rgba(33, 150, 243, 0.3);
  --shadow-lg: 0 8px 20px rgba(33, 150, 243, 0.4);
  --shadow-xl: 0 12px 28px rgba(0, 0, 0, 0.15);
  --shadow-button: 0 4px 12px rgba(76, 175, 80, 0.3);
  --shadow-button-hover: 0 6px 16px rgba(76, 175, 80, 0.4);

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Gradients */
  --gradient-primary-bg: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  --gradient-card: linear-gradient(135deg, #64B5F6 0%, #42A5F5 100%);
  --gradient-button: linear-gradient(135deg, #66BB6A 0%, #4CAF50 100%);
}

/* ============================================================================
   Base Styles & Reset
   ========================================================================= */

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

body {
  font-family: var(--font-family);
  font-size: var(--font-body-size);
  font-weight: var(--font-body-weight);
  line-height: var(--line-height-normal);
  color: var(--color-gray-800);
  background: var(--gradient-primary-bg);
  min-height: 100vh;
}

/* ============================================================================
   Typography
   ========================================================================= */

h1 {
  font-size: var(--font-h1-size);
  font-weight: var(--font-h1-weight);
  line-height: var(--line-height-tight);
  color: var(--color-sky-700);
}

h2 {
  font-size: var(--font-h2-size);
  font-weight: var(--font-h2-weight);
  line-height: var(--line-height-tight);
  color: var(--color-sky-700);
}

h3 {
  font-size: var(--font-h3-size);
  font-weight: var(--font-h3-weight);
  line-height: var(--line-height-tight);
  color: var(--color-sky-700);
}

h4 {
  font-size: var(--font-h4-size);
  font-weight: var(--font-h4-weight);
  line-height: var(--line-height-tight);
  color: var(--color-sky-700);
}

p {
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-800);
}

strong, .text-bold {
  font-weight: var(--font-body-bold-weight);
}

.text-small {
  font-size: var(--font-small-size);
  font-weight: var(--font-small-weight);
}

.text-tiny {
  font-size: var(--font-tiny-size);
  font-weight: var(--font-tiny-weight);
}

/* ============================================================================
   Layout Patterns
   ========================================================================= */

.container-full-height {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.layout-horizontal {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: var(--space-5);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-5);
}

.carousel {
  display: flex;
  gap: var(--space-5);
  overflow-x: auto;
  padding-bottom: 5px;
}

/* ============================================================================
   Buttons
   ========================================================================= */

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--transition-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-primary {
  background: var(--gradient-button);
  color: var(--color-white);
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  font-size: var(--font-body-size);
  font-weight: var(--font-body-bold-weight);
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-button-hover);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--color-sky-400);
  color: var(--color-white);
  padding: 12px 24px;
  border-radius: 20px;
  font-size: var(--font-body-size);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-sky-500);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: 8px 16px;
  font-size: var(--font-body-size);
  font-weight: 500;
  box-shadow: none;
}

.btn-text:hover {
  color: var(--color-primary-dark);
  background: rgba(66, 165, 245, 0.1);
}

/* ============================================================================
   Cards
   ========================================================================= */

.card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-xl);
  padding: 20px 25px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.card-interactive {
  min-width: 200px;
  height: 120px;
  background: var(--color-sky-400);
  border-radius: var(--radius-xl);
  color: white;
  font-weight: var(--font-body-bold-weight);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  transition: all var(--transition-base);
}

.card-interactive:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.card-interactive.active {
  background: var(--color-primary);
}

.card-header {
  font-size: var(--font-h4-size);
  font-weight: var(--font-h4-weight);
  margin-bottom: var(--space-3);
  color: var(--color-sky-700);
}

/* ============================================================================
   Status Badges
   ========================================================================= */

.status-badge {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 3px solid white;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
}

.status-badge:hover {
  transform: scale(1.3);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.status-badge:active {
  transform: scale(1.1);
}

.status-badge.done {
  background: var(--color-success);
}

.status-badge.progress {
  background: var(--color-warning);
}

.status-badge.empty {
  background: var(--color-error);
}

/* ============================================================================
   Forms
   ========================================================================= */

.input {
  background: white;
  border: 2px solid var(--color-sky-50);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--font-body-size);
  font-family: var(--font-family);
  color: var(--color-gray-800);
  transition: border-color var(--transition-fast);
  width: 100%;
}

.input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.1);
}

.textarea {
  background: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: 30px;
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-800);
  box-shadow: 0 2px 12px rgba(33, 150, 243, 0.15);
  resize: vertical;
  font-family: var(--font-family);
  font-size: var(--font-body-size);
  width: 100%;
  min-height: 150px;
}

.textarea:focus {
  outline: none;
  box-shadow: 0 2px 12px rgba(33, 150, 243, 0.25);
}

/* ============================================================================
   Sidebar / Panels
   ========================================================================= */

.sidebar {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-width: 320px;
}

.sidebar-header {
  background: var(--gradient-card);
  padding: 25px;
  color: white;
  font-weight: var(--font-body-bold-weight);
  font-size: var(--font-h4-size);
  text-align: center;
}

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

.sidebar-item {
  padding: 18px 25px;
  border-bottom: 1px solid var(--color-sky-50);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-item:hover {
  background: var(--color-sky-50);
  transform: translateX(5px);
}

.sidebar-item.active {
  background: var(--color-sky-100);
  border-left: 4px solid var(--color-primary);
}

/* ============================================================================
   Scrollbars
   ========================================================================= */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-sky-50);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--color-sky-400);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-sky-500);
}

/* ============================================================================
   Icons
   ========================================================================= */

.icon-sm {
  font-size: 16px;
}

.icon-md {
  font-size: 32px;
}

.icon-lg {
  font-size: 48px;
}

.icon-xl {
  font-size: 64px;
}

/* ============================================================================
   Animations & States
   ========================================================================= */

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.fade-in {
  animation: fadeIn var(--transition-base);
}

/* ============================================================================
   Empty States
   ========================================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16);
  text-align: center;
  color: var(--color-sky-300);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: var(--font-h3-size);
  font-weight: var(--font-h3-weight);
  margin-bottom: var(--space-2);
  color: var(--color-sky-400);
}

.empty-state-description {
  font-size: var(--font-body-size);
  color: var(--color-gray-500);
}

/* ============================================================================
   Notifications / Toasts
   ========================================================================= */

.toast {
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-md);
  color: white;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.toast-success {
  background: var(--color-success);
  box-shadow: 0 4px 12px rgba(102, 187, 106, 0.3);
}

.toast-error {
  background: var(--color-error);
  box-shadow: 0 4px 12px rgba(239, 83, 80, 0.3);
}

.toast-warning {
  background: var(--color-warning);
  box-shadow: 0 4px 12px rgba(255, 202, 40, 0.3);
}

/* ============================================================================
   Utilities
   ========================================================================= */

/* Spacing utilities */
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.p-10 { padding: var(--space-10); }

.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-5 { margin: var(--space-5); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }
.m-10 { margin: var(--space-10); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }

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

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

.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.text-gray { color: var(--color-gray-600); }

/* Background utilities */
.bg-white { background: var(--color-white); }
.bg-gradient { background: var(--gradient-primary-bg); }
.bg-primary { background: var(--color-primary); }
.bg-sky-light { background: var(--color-sky-50); }

/* Border radius utilities */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow utilities */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

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

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

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

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

/* ============================================================================
   Accessibility
   ========================================================================= */

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Ensure minimum touch targets on mobile */
@media (hover: none) and (pointer: coarse) {
  button, .btn, a {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ============================================================================
   Responsive Design
   ========================================================================= */

/* Mobile */
@media (max-width: 640px) {
  .layout-horizontal {
    flex-direction: column;
    gap: var(--space-4);
  }

  .sidebar {
    min-width: 100%;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    padding: 16px 24px;
  }

  h1 { font-size: 18px; }
  h2 { font-size: 20px; }
  h3 { font-size: 16px; }
}

/* Tablet */
@media (max-width: 1024px) {
  .sidebar {
    min-width: 280px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .card-interactive {
    min-width: 150px;
    height: 100px;
  }
}
