/* FaxBackRx App CSS - Light Professional Theme */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #059669;
  --accent-light: #ecfdf5;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 8px;
  --radius-lg: 16px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --nav-height: 60px;
  --tab-height: 52px;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-alt);
  font-size: 15px;
  line-height: 1.5;
}

/* Logo */
.logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.logo-icon { font-size: 20px; }
.logo-accent { color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1;
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--accent-light); color: #065f46; border: 1px solid #a7f3d0; }

/* Form elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.form-group-narrow { max-width: 200px; }
.form-group-short { max-width: 100px; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
textarea,
.select-control {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  line-height: 1.4;
}

input:focus, textarea:focus, .select-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea { resize: vertical; min-height: 96px; }

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row-3 { }

.required { color: var(--danger); }

.form-section { margin-bottom: 28px; }

.form-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.form-legal {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
}

.form-legal a { color: var(--primary); }

/* ============================
   AUTH PAGES
   ============================ */

.auth-page {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 440px;
}

.auth-container-wide { max-width: 680px; }

.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-header .logo {
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.auth-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* Form groups inside auth card */
.auth-card .form-group {
  margin-bottom: 16px;
}

/* ============================
   APP LAYOUT
   ============================ */

.app-page {
  background: var(--bg-alt);
  min-height: 100vh;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: var(--nav-height);
  gap: 16px;
}

.nav-pharmacy {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.tab-bar {
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  min-width: 120px;
  padding: 0 16px;
  height: var(--tab-height);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

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

.tab-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.tab-inner h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: left;
}

/* ============================
   DASHBOARD
   ============================ */

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.dashboard-header h2 { margin-bottom: 0; }

.dashboard-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.status-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.status-count {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.status-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.status-card-queued .status-count { color: var(--text-muted); }
.status-card-sent .status-count { color: var(--primary); }
.status-card-resolved .status-count { color: var(--accent); }
.status-card-failed .status-count { color: var(--danger); }

/* Fax items */
.fax-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}

.fax-item-left { flex: 1; min-width: 0; }

.fax-item-drug {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.fax-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.fax-item-meta span::after {
  content: ' |';
  margin-left: 8px;
  color: var(--border);
}

.fax-item-meta span:last-child::after { content: ''; }

.fax-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-queued { background: #f1f5f9; color: var(--text-muted); }
.status-sent { background: #dbeafe; color: var(--primary-dark); }
.status-resolved { background: var(--accent-light); color: #065f46; }
.status-failed { background: var(--danger-light); color: var(--danger); }
.status-cancelled { background: #f1f5f9; color: var(--text-muted); }

/* Pagination */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.pagination button:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 14px;
}

/* ============================
   NEW FAX FORM
   ============================ */

.issue-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.issue-type-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-family: var(--font);
}

.issue-type-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.issue-type-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.issue-type-btn strong {
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
}

.issue-type-btn small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ============================
   PRESCRIBERS
   ============================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 { margin-bottom: 0; }

.form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.form-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.prescriber-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}

.prescriber-info { flex: 1; min-width: 0; }

.prescriber-info h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.prescriber-info p {
  font-size: 13px;
  color: var(--text-muted);
}

.prescriber-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================
   SETTINGS
   ============================ */

.settings-form { max-width: 680px; }

.subscription-banner {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 24px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border: 4px solid var(--bg-alt); border-radius: 8px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; border: 4px solid var(--bg-alt); background-clip: padding-box; }

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
  .status-cards { grid-template-columns: repeat(2, 1fr); }
  .issue-type-grid { grid-template-columns: repeat(2, 1fr); }
  .fax-item { flex-direction: column; align-items: flex-start; }
  .fax-item-right { width: 100%; justify-content: flex-start; }

  .tab-btn {
    min-width: 90px;
    font-size: 12px;
    padding: 0 10px;
  }

  .auth-card { padding: 28px 20px; }
  .form-row { flex-direction: column; gap: 0; }
  .form-group-narrow, .form-group-short { max-width: 100%; }
}

@media (max-width: 480px) {
  .issue-type-grid { grid-template-columns: 1fr 1fr; }
  .status-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-header { flex-direction: column; align-items: flex-start; }
}
