/* ===============================================
   MedFlip Profit - Design System
   Modern SaaS UI inspired by industry leaders
   =============================================== */

/* Custom CSS Variables - Brand Design System */
:root {
  /* Primary Brand Colors - Medical/Professional Palette */
  --brand-primary: #667eea;
  --brand-primary-dark: #5568d3;
  --brand-secondary: #764ba2;
  --brand-accent: #28a745;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  --gradient-card: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  
  /* Semantic Colors */
  --color-success: #28a745;
  --color-success-bg: #e5ffea;
  --color-error: #dc3545;
  --color-error-bg: #ffe5e5;
  --color-warning: #ffc107;
  --color-warning-bg: #fff3cd;
  --color-info: #17a2b8;
  --color-info-bg: #d1ecf1;
  
  /* Neutral Palette */
  --color-gray-50: #f8f9fa;
  --color-gray-100: #e9ecef;
  --color-gray-200: #dee2e6;
  --color-gray-300: #ced4da;
  --color-gray-400: #adb5bd;
  --color-gray-500: #6c757d;
  --color-gray-600: #495057;
  --color-gray-700: #343a40;
  --color-gray-800: #212529;
  
  /* Typography Scale */
  --font-size-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --font-size-sm: clamp(0.875rem, 0.8rem + 0.3vw, 0.9375rem);
  --font-size-base: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  --font-size-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
  --font-size-3xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
  
  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 300ms ease-in-out;
  --transition-slow: 500ms ease-in-out;
}

/* ===============================================
   Global Resets & Typography
   =============================================== */

body {
  font-size: var(--font-size-base);
  line-height: 1.6;
}

h1 { font-size: var(--font-size-3xl); font-weight: 700; line-height: 1.2; }
h2 { font-size: var(--font-size-2xl); font-weight: 600; line-height: 1.3; }
h3 { font-size: var(--font-size-xl); font-weight: 600; line-height: 1.4; margin-top: var(--space-xl); margin-bottom: var(--space-md); }
h4 { font-size: var(--font-size-lg); font-weight: 600; line-height: 1.4; }

/* ===============================================
   Modern Card Components
   =============================================== */

.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  border-bottom: 1px solid var(--color-gray-200);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-lg);
}

.card-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin: 0;
  color: var(--color-gray-800);
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-gray-500);
  margin-top: var(--space-xs);
}

/* KPI Cards for Dashboard */
.kpi-card {
  background: var(--gradient-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--brand-primary);
  margin: var(--space-sm) 0;
}

.kpi-label {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===============================================
   Badges & Chips
   =============================================== */

.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

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

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

.badge-warning {
  background: var(--color-warning-bg);
  color: #856404;
}

.badge-info {
  background: var(--color-info-bg);
  color: #0c5460;
}

.badge-primary {
  background: #e7e9fc;
  color: var(--brand-primary);
}

/* Status Chips for Deals */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

/* Ensure select elements show text properly */
select.status-chip {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.status-new { background: #e3f2fd !important; color: #1976d2 !important; }
.status-quoted { background: #fff3e0 !important; color: #e65100 !important; }
.status-label-sent { background: #f3e5f5 !important; color: #7b1fa2 !important; }
.status-received { background: #e8f5e9 !important; color: #2e7d32 !important; }
.status-paid { background: #c8e6c9 !important; color: #1b5e20 !important; font-weight: 600; }
.status-closed-lost { background: #ffebee !important; color: #c62828 !important; }

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

button, 
a[role="button"],
input[type="submit"] {
  height: auto;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-base);
  cursor: pointer;
}

button:hover:not(:disabled),
a[role="button"]:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Primary Gradient Button */
.btn-gradient {
  background: var(--gradient-primary);
  color: white;
  border: none;
  font-weight: 600;
}

.btn-gradient:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6639a5 100%);
}

/* Success Button */
.btn-success {
  background: var(--color-success);
  color: white;
  border: none;
}

.btn-success:hover {
  background: #218838;
}

/* Outline Button */
.btn-outline {
  background: transparent;
  border: 2px solid var(--brand-primary);
  color: var(--brand-primary);
}

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

.button-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-md);
  justify-content: flex-start;
}

.button-group.right {
  justify-content: flex-end;
}

.button-group.center {
  justify-content: center;
}

@media (max-width: 768px) {
  .button-group {
    flex-direction: column;
  }
  
  .button-group button,
  .button-group a[role="button"] {
    width: 100%;
  }
}

.button-group button,
.button-group a[role="button"] {
  min-width: 120px;
  margin: 0;
}

form button[type="submit"] {
  min-width: 150px;
}

table a[role="button"] {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  min-width: auto;
  white-space: nowrap;
  display: inline-block;
  text-align: center;
}

/* ===============================================
   Enhanced Tables (Mobile Responsive)
   =============================================== */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead {
  background: var(--color-gray-50);
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  font-weight: 600;
  text-align: left;
  padding: var(--space-md);
  border-bottom: 2px solid var(--color-gray-300);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-gray-700);
}

tbody tr {
  border-bottom: 1px solid var(--color-gray-200);
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background: var(--color-gray-50);
}

tbody td {
  padding: var(--space-md);
  vertical-align: middle;
}

/* Mobile Table - Card View */
@media (max-width: 768px) {
  .table-wrapper {
    box-shadow: none;
  }
  
  table.mobile-cards {
    border: 0;
  }
  
  table.mobile-cards thead {
    display: none;
  }
  
  table.mobile-cards tbody tr {
    display: block;
    margin-bottom: var(--space-md);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: none;
  }
  
  table.mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    border: none;
    text-align: right;
  }
  
  table.mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    color: var(--color-gray-600);
  }
  
  table.mobile-cards tbody td:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--color-gray-50);
    font-weight: 600;
  }
  
  table.mobile-cards tbody td:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
}

/* ===============================================
   Forms & Inputs
   =============================================== */

label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--color-gray-700);
  font-size: var(--font-size-sm);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Touch-friendly inputs on mobile */
@media (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-md);
  }
}

/* ===============================================
   Flash Messages
   =============================================== */

article.success {
  background: var(--color-success-bg);
  border-left: 4px solid var(--color-success);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
}

article.error {
  background: var(--color-error-bg);
  border-left: 4px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* ===============================================
   Grid & Layout Utilities
   =============================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

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

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

@media (max-width: 768px) {
  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ===============================================
   Spacing & Utility Classes
   =============================================== */

.mt { margin-top: var(--space-md); }
.mb { margin-bottom: var(--space-md); }
.mt-lg { margin-top: var(--space-xl); }
.mb-lg { margin-bottom: var(--space-xl); }

section {
  margin-bottom: var(--space-xl);
}

/* ===============================================
   Filter & Details Sections
   =============================================== */

details[open] {
  margin-bottom: var(--space-lg);
}

details summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--space-md);
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-base);
}

details summary:hover {
  background: var(--color-gray-100);
}

/* ===============================================
   Modern Navigation System
   =============================================== */

.app-nav {
  background: white;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: 0 !important;
}

.nav-brand {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  font-size: var(--font-size-xl);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-base);
  text-decoration: none;
  color: var(--color-gray-700);
}

.nav-item:hover {
  background: var(--color-gray-50);
  color: var(--brand-primary);
}

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

/* Dropdown Menu Styles */
.nav-dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  margin-top: var(--space-xs);
  z-index: 1000;
  list-style: none;
}

.nav-dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu li {
  margin: 0;
  padding: 0;
}

.dropdown-menu a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-gray-700);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-base);
}

.dropdown-menu a:hover {
  background: var(--color-gray-50);
  color: var(--brand-primary);
}

/* Mobile Menu Toggle */
.mobile-only {
  display: none;
  margin-left: auto;
}

.mobile-menu-toggle {
  display: none;
  background: var(--brand-primary);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.mobile-menu-toggle:hover {
  background: var(--brand-secondary);
  transform: scale(1.05);
}

/* Auth Cards */
.auth-card {
  background: white;
  padding: 3rem 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-gray-200);
}

.auth-card h2 {
  color: var(--color-gray-800);
  font-weight: 700;
}

.auth-card label {
  font-weight: 500;
  color: var(--color-gray-800);
  margin-top: 1rem;
}

.auth-card input {
  margin-top: 0.5rem;
}

.auth-card a {
  color: var(--brand-primary);
  font-weight: 500;
}

.info-box {
  background: var(--color-gray-50);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--brand-primary);
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .app-nav ul:last-child {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    padding: var(--space-md);
    gap: var(--space-xs);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
  }
  
  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .app-nav ul:last-child.show {
    display: flex;
  }
  
  .app-nav ul:last-child li {
    width: 100%;
  }
  
  .app-nav ul:last-child li a {
    display: block;
    width: 100%;
  }
}

/* ===============================================
   Floating Action Button (Mobile)
   =============================================== */

.fab {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  box-shadow: var(--shadow-xl);
  cursor: pointer;
  transition: transform var(--transition-base);
  z-index: 1000;
  border: none;
  text-decoration: none;
}

.fab:hover {
  transform: scale(1.1);
  color: white;
}

@media (min-width: 769px) {
  .fab {
    display: none;
  }
}

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

.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-gray-500);
}

.empty-state-icon {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--color-gray-700);
  margin-top: var(--space-md);
}

.empty-state p {
  color: var(--color-gray-500);
  max-width: 500px;
  margin: var(--space-md) auto;
}
