/* WhistleSafe — Main Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --secondary: #6B7280;
  --bg: #F9FAFB;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text: #111827;
  --muted: #6B7280;
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  --radius: 8px;
  --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);
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 1.5rem; }
.page { min-height: 100vh; }

/* Navigation */
.navbar { background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; }
.navbar-inner { display: flex; align-items: center; justify-content: space-between;
  height: 64px; }
.navbar-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700;
  font-size: 1.25rem; color: var(--primary); }
.navbar-brand img { height: 36px; }
.navbar-links { display: flex; gap: 1.5rem; align-items: center; }
.navbar-links a { color: var(--muted); font-size: .9rem; transition: color .2s; }
.navbar-links a:hover, .navbar-links a.active { color: var(--primary); text-decoration: none; }

/* Sidebar layout */
.app-layout { display: flex; min-height: calc(100vh - 64px); }
.sidebar { width: 240px; background: var(--card); border-right: 1px solid var(--border);
  padding: 1.5rem 0; flex-shrink: 0; }
.sidebar-item { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem;
  color: var(--muted); font-size: .9rem; cursor: pointer; transition: all .2s; }
.sidebar-item:hover, .sidebar-item.active { background: rgba(59,130,246,.08);
  color: var(--primary); text-decoration: none; }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.main-content { flex: 1; padding: 2rem; overflow: auto; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 1.1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }

/* Stat cards */
.stat-card { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.stat-label { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.stat-value { font-size: 2rem; font-weight: 700; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: .625rem .875rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .9rem; background: var(--card);
  transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea { resize: vertical; min-height: 100px; }
.help-text { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem 1.25rem;
  border-radius: var(--radius); font-size: .9rem; font-weight: 500; cursor: pointer;
  border: none; transition: all .2s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .875rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Alerts */
.alert { padding: .875rem 1.25rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.alert-success { background: #F0FDF4; border: 1px solid #BBF7D0; color: #166534; }
.alert-info { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem;
  border-radius: 99px; font-size: .75rem; font-weight: 500; }
.badge-new { background: #EFF6FF; color: #1E40AF; }
.badge-review { background: #FFF7ED; color: #92400E; }
.badge-resolved { background: #F0FDF4; color: #166534; }
.badge-closed { background: #F3F4F6; color: #374151; }
.badge-active { background: #F0FDF4; color: #166534; }
.badge-suspended { background: #FEF2F2; color: #991B1B; }
.badge-free { background: #F3F4F6; color: #374151; }
.badge-basic { background: #EFF6FF; color: #1E40AF; }
.badge-premium { background: #FDF4FF; color: #6B21A8; }
.badge-enterprise { background: #FFF7ED; color: #9A3412; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); padding: .75rem 1rem;
  border-bottom: 2px solid var(--border); background: var(--bg); }
td { padding: .875rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #F9FAFB; }

/* Hero */
.hero { text-align: center; padding: 5rem 1rem 3rem; }
.hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.2; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; color: var(--muted); max-width: 560px; margin: 0 auto 2rem; }

/* Feature grid */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem; margin: 2rem 0; }
.feature-card { text-align: center; padding: 2rem 1.5rem; }
.feature-icon { width: 56px; height: 56px; border-radius: 50%;
  background: rgba(59,130,246,.1); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem; }
.feature-icon svg { width: 28px; height: 28px; color: var(--primary); }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: .875rem; color: var(--muted); }

/* Search/filter bar */
.toolbar { display: flex; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 180px; }

/* Dialog overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 999;
  opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 2rem; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; }
.modal-title { font-size: 1.2rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.5rem;
  color: var(--muted); line-height: 1; }

/* Form builder */
.form-builder { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; }
.field-palette { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; }
.field-type-btn { display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .6rem .75rem; margin-bottom: .4rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: .875rem; transition: all .2s; }
.field-type-btn:hover { background: rgba(59,130,246,.05); border-color: var(--primary); }
.canvas-area { display: flex; flex-direction: column; gap: 1rem; }
.field-card { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; cursor: grab; }
.field-card:active { cursor: grabbing; }
.field-card-header { display: flex; align-items: center; justify-content: space-between; }

/* Checklist / radio groups */
.check-group { display: flex; flex-direction: column; gap: .5rem; }
.check-group label { display: flex; align-items: center; gap: .5rem; font-weight: 400;
  cursor: pointer; }

/* Color swatch */
.color-wrap { display: flex; align-items: center; gap: .75rem; }
.color-wrap input[type=color] { width: 48px; height: 40px; padding: 2px;
  border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer; }

/* Footer */
footer { border-top: 1px solid var(--border); padding: 1.5rem 0; margin-top: 3rem; }
footer p { font-size: .875rem; color: var(--muted); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .hero h1 { font-size: 2rem; }
  .form-builder { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
