/* ==========================================================================
   Sajilo Bill - Shared Base Stylesheet
   Reusable design tokens, resets, typography, buttons, and form inputs.
   ========================================================================== */

/* --- Design Tokens (CSS Variables) --- */
:root {
  /* Brand & Theme Colors */
  --color-primary: #eb1a20;
  --color-primary-hover: #c81419;
  --color-primary-active: #a80f14;
  --color-primary-light: #fef2f2;
  --color-primary-subtle: #fee2e2;

  /* Neutral & Text Colors */
  --color-text-dark: #0f172a;       /* slate-900 */
  --color-text-body: #334155;       /* slate-700 */
  --color-text-muted: #64748b;      /* slate-500 */
  --color-text-light: #94a3b8;      /* slate-400 */
  --color-white: #ffffff;
  --color-bg-page: #f8fafc;         /* slate-50 */
  --color-bg-card: #ffffff;

  /* Borders & Dividers */
  --color-border: #e2e8f0;          /* slate-200 */
  --color-border-hover: #cbd5e1;    /* slate-300 */
  --color-border-focus: #eb1a20;

  /* State / Feedback Colors */
  --color-danger: #dc2626;          /* red-600 */
  --color-danger-bg: #fef2f2;       /* red-50 */
  --color-danger-border: #fecaca;   /* red-200 */
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;

  /* Typography */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;

  /* Spacing Scale */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */

  /* Border Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Minimum touch target size for mobile accessibility */
  --touch-target-min: 48px;
}

/* --- Box Sizing & Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-body);
  background-color: var(--color-bg-page);
  min-height: 100vh;
}

/* --- Typography Defaults --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-dark);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}

p {
  margin: 0;
}

/* --- Form Controls: Groups, Labels & Inputs --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  text-align: left;
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-dark);
  cursor: pointer;
}

.form-label-required::after {
  content: " *";
  color: var(--color-danger);
}

.input-control {
  width: 100%;
  height: var(--touch-target-min);
  padding: 0 var(--space-4);
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text-dark);
  background-color: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.input-control::placeholder {
  color: var(--color-text-light);
}

.input-control:hover:not(:disabled) {
  border-color: var(--color-border-hover);
}

.input-control:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(235, 26, 32, 0.12);
}

.input-control:disabled {
  background-color: #f1f5f9;
  color: var(--color-text-light);
  cursor: not-allowed;
}

/* Invalid state for input fields */
.input-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* --- Button Styles --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target-min);
  padding: 0 var(--space-5);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, #eb1a20 0%, #c81419 100%);
  color: var(--color-white);
  box-shadow: 0 4px 12px rgba(235, 26, 32, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #c81419 0%, #a80f14 100%);
  box-shadow: 0 6px 16px rgba(235, 26, 32, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: #93c5fd;
  color: #ffffff;
  cursor: not-allowed;
  box-shadow: none;
}

/* Secondary Button */
.btn-secondary {
  background-color: #ffffff;
  color: var(--color-text-dark);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: #f8fafc;
  border-color: var(--color-border-hover);
}

/* Danger Button */
.btn-danger {
  background-color: var(--color-danger);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28);
}

.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
}

/* Block (Full-Width) Button */
.btn-block {
  width: 100%;
}

/* --- Inline Alert / Error Notice --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  margin-bottom: var(--space-4);
}

.alert-danger {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.alert-hidden {
  display: none !important;
}

/* --- Accessibility Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Universal Global Guard for Logout & Header Icons */
.btn-logout {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  border-radius: 8px !important;
  border: 1px solid #E2E8F0 !important;
  background-color: #F8FAFC !important;
  color: #64748B !important;
  text-decoration: none !important;
  overflow: hidden !important;
}
.btn-logout:hover {
  background-color: #FEF2F2 !important;
  color: #B91C1C !important;
  border-color: #FEE2E2 !important;
}
.logout-icon {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;
  display: block !important;
  flex-shrink: 0 !important;
}
