@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ============================================================
   CSS Custom Properties — Design Tokens
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-body: #f4f7f9;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-sidebar: #ffffff;
  --bg-input: rgba(0, 0, 0, 0.03);

  /* Accent & Brand */
  --accent: #4f46e5;
  --accent-alt: #6366f1;
  --accent-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --accent-glow: rgba(79, 70, 229, 0.35);
  --accent-light: rgba(79, 70, 229, 0.12);

  /* Status */
  --success: #059669;
  --success-light: rgba(16, 185, 129, 0.12);
  --warning: #d97706;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger: #dc2626;
  --danger-light: rgba(239, 68, 68, 0.12);
  --info: #2563eb;
  --info-light: rgba(59, 130, 246, 0.12);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;

  /* Borders */
  --border: rgba(0, 0, 0, 0.1);
  --border-hover: rgba(0, 0, 0, 0.18);
  --border-focus: var(--accent);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.25);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.06);

  /* Layout */
  --sidebar-w: 265px;
  --header-h: 45px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Transitions */
  --t-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 1);
  --glass-blur: blur(20px);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  background-image: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--t-fast);
}

a:hover {
  color: var(--accent-alt);
}

img {
  max-width: 100%;
  display: block;
}

ul,
ol {
  list-style: none;
}

::selection {
  background: var(--accent);
  color: #fff;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ============================================================
   Typography
   ============================================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1rem;
}

p {
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-accent {
  color: var(--accent) !important;
}

.text-sm {
  font-size: 12px;
}

.text-lg {
  font-size: 16px;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

/* ============================================================
   Layout — App Shell
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  /* Vibrant Corporate Blue Theme */
  --bg-sidebar: #0041f3;
  --text-primary: #ffffff;
  --text-secondary: #e0e7ff;
  --text-muted: #93c5fd;
  --border: rgba(255, 255, 255, 0.15);
  --accent: #ffffff;
  --accent-light: rgba(255, 255, 255, 0.15);
  --accent-grad: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);

  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--t-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  height: var(--header-h);
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: var(--accent-grad);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: -2px;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.75rem 1.25rem 0.4rem;
  margin-top: 0.5rem;
}

.nav-section-label.active-section {
  color: var(--accent);
}


.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: var(--t-fast);
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-light);
  border-right: 3px solid var(--accent);
}

.nav-item .nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  transition: var(--t-fast);
}

.nav-item:hover .nav-icon {
  background: rgba(255, 255, 255, 0.2);
}

.nav-item.active .nav-icon {
  opacity: 1;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

/* Sidebar specific overrides for avatar since accent-grad is white */
.sidebar .avatar {
  color: var(--bg-sidebar);
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.sidebar-user-info .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-user-info .user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ============================================================
   Top Header Bar
   ============================================================ */
.public-header {
  padding: 1rem 2rem;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header {
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 1rem;
}

.page-title-area .page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-title-area .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-time {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

/* ============================================================
   Main Content Area
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-primary);
}

.content-area {
  padding: 1.75rem;
  flex: 1;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: var(--t-base);
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
}

/* Submit Page Layout */
.submit-page {
  background-color: var(--bg-tertiary);
  min-height: calc(100vh - 65px);
  padding: 2rem 1rem;
}

.submit-container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: var(--t-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-grad);
  opacity: 0;
  transition: var(--t-base);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.purple {
  background: var(--accent-light);
  color: var(--accent);
}

.stat-icon.green {
  background: var(--success-light);
  color: var(--success);
}

.stat-icon.yellow {
  background: var(--warning-light);
  color: var(--warning);
}

.stat-icon.red {
  background: var(--danger-light);
  color: var(--danger);
}

.stat-icon.blue {
  background: var(--info-light);
  color: var(--info);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 3px;
}

.stat-change {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
}

.stat-change.up {
  color: var(--success);
}

.stat-change.down {
  color: var(--danger);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px var(--accent-glow);
  color: #fff;
}

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

.btn-secondary {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.10);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #0ea271;
  color: #fff;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  color: #fff;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-warning:hover:not(:disabled) {
  background: #d97706;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-light);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 12px;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 15px;
}

.btn-icon {
  padding: 0.45rem;
  width: 34px;
  height: 34px;
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  padding: 0.25rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   Forms / Inputs
   ============================================================ */
.form-group {
  margin-bottom: 1.1rem;
}

.form-row {
  display: grid;
  gap: 1rem;
}

.form-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 3px;
}

.form-control,
.form-select {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  padding: 0.6rem 0.9rem;
  transition: var(--t-fast);
  outline: none;
}

.form-select {
  -webkit-appearance: none;
  appearance: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background-color: rgba(0, 0, 0, 0.06);
}

.form-control:hover:not(:focus),
.form-select:hover:not(:focus) {
  border-color: var(--border-hover);
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

.form-select {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBmaWxsPSIjNjQ3NDhiIiBkPSJNNCA2bDQgNCA0LTR6Ii8+PC/zdmc+");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.form-error {
  font-size: 11.5px;
  color: var(--danger);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

.form-check-input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-check-label {
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

/* Toggle Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toggle {
  display: inline-block;
  position: relative;
  width: 44px;
  height: 24px;
  vertical-align: middle;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--t-base);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: var(--t-base);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked+.toggle-slider {
  background: var(--accent);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

/* File Input */
.file-drop-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--t-base);
  background: var(--bg-input);
  position: relative;
}

.file-drop-area:hover,
.file-drop-area.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.file-drop-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-drop-icon {
  font-size: 32px;
  margin-bottom: 0.5rem;
  opacity: 0.6;
}

.file-drop-text {
  font-size: 13px;
  color: var(--text-muted);
}

.file-drop-types {
  font-size: 11px;
  color: var(--text-disabled);
  margin-top: 0.25rem;
}

/* Range Input */
.form-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 99px;
  outline: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: var(--t-fast);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Star Rating */
.star-rating {
  display: flex;
  gap: 4px;
}

.star-rating .star {
  font-size: 22px;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.15);
  transition: var(--t-fast);
}

.star-rating .star.active,
.star-rating .star:hover,
.star-rating .star:hover~.star {
  color: var(--warning);
}

/* Signature Pad */
.signature-pad-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.03);
  position: relative;
}

.signature-pad-wrap canvas {
  width: 100%;
  display: block;
  cursor: crosshair;
}

.signature-clear {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead tr {
  background: rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 0.8rem 1rem;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--t-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(0, 0, 0, 0.025);
}

tbody td {
  padding: 0.8rem 1rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody td.td-primary {
  color: var(--text-primary);
  font-weight: 500;
}

tbody td.td-mono {
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-primary {
  background: var(--accent-light);
  color: var(--accent);
}

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

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

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

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-muted {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-muted);
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  position: relative;
  margin-bottom: 1rem;
  border-left: 3px solid transparent;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border-color: var(--warning);
}

.alert-info {
  background: var(--info-light);
  color: var(--info);
  border-color: var(--info);
}

.alert-dismissible {
  padding-right: 2.5rem;
}

.alert-close {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: currentColor;
  opacity: 0.7;
  line-height: 1;
}

.alert-close:hover {
  opacity: 1;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--t-base);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: var(--t-base);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-lg {
  max-width: 820px;
}

.modal-xl {
  max-width: 1100px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t-fast);
}

.modal-close:hover {
  background: var(--danger);
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.65rem 1.25rem;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--t-fast);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ============================================================
   Search & Filter Bar
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-input-wrap .form-control {
  padding-left: 2.25rem;
}

/* ============================================================
   Form Builder Specific
   ============================================================ */
.builder-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  min-height: 600px;
}

.builder-library {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.builder-library-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.builder-field-list {
  overflow-y: auto;
  flex: 1;
}

.builder-field-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--t-fast);
}

.builder-field-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.builder-field-item.in-form {
  background: var(--accent-light);
}

.builder-field-item .field-type-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.builder-field-item .field-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.builder-field-item .field-type-badge {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.builder-canvas {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.builder-canvas-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-fields-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.form-field-row {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: grab;
  transition: var(--t-fast);
  position: relative;
}

.form-field-row:hover {
  border-color: var(--border-hover);
}

.form-field-row.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.form-field-row.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.drag-handle {
  color: var(--text-muted);
  font-size: 16px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.form-field-row .field-info {
  flex: 1;
}

.form-field-row .field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-field-row .field-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  text-align: center;
}

.empty-canvas .empty-icon {
  font-size: 40px;
  opacity: 0.3;
}

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

/* ============================================================
   Status Indicators
   ============================================================ */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 12px;
  font-weight: 600;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.enabled::before {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-dot.disabled::before {
  background: var(--text-muted);
}

.status-dot.open::before {
  background: var(--info);
  box-shadow: 0 0 6px var(--info);
}

.status-dot.closed::before {
  background: var(--danger);
}

/* ============================================================
   PIN Display
   ============================================================ */
.pin-display {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}

.pin-digit {
  width: 52px;
  height: 64px;
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  align-items: center;
  padding: 1rem 0 0;
}

.page-btn {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--t-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   Progress Bar
   ============================================================ */
.progress {
  height: 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--accent-grad);
  transition: width 0.5s ease;
}

.progress-bar.success {
  background: var(--success);
}

.progress-bar.warning {
  background: var(--warning);
}

.progress-bar.danger {
  background: var(--danger);
}

/* ============================================================
   Score Display
   ============================================================ */
.score-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--accent-glow);
}

.score-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.score-max {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   Public Submission Form
   ============================================================ */
.public-page {
  min-height: 100vh;
  background: var(--bg-body);
  display: flex;
  flex-direction: column;
}

.public-nav {
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.public-hero {
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-tertiary));
  padding: 3rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.public-hero::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: var(--accent-grad);
  border-radius: 50%;
  opacity: 0.07;
  top: -100px;
  right: -100px;
  filter: blur(60px);
}

.public-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  flex: 1;
}

.submission-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.submission-form-header {
  padding: 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  position: relative;
}

.submission-form-body {
  padding: 2rem;
}

.pin-input-form {
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.pin-input-big {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.8rem;
  text-align: center;
  font-family: 'Courier New', monospace;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--accent);
  padding: 1rem;
  width: 100%;
  margin: 1rem 0;
}

.pin-input-big:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
  outline: none;
}

/* ============================================================
   Confirmation Page
   ============================================================ */
.confirmation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.confirmation-success {
  text-align: center;
  padding: 2.5rem;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  border-bottom: 1px solid var(--border);
}

.success-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 1rem;
  animation: bounceIn 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.submission-id-box {
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  text-align: center;
  letter-spacing: 0.1rem;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ============================================================
   Loader
   ============================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ============================================================
   Dropdown Menu
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 150;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--t-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  text-decoration: none;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: var(--danger-light);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============================================================
   Tooltips
   ============================================================ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary);
  font-size: 11.5px;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: var(--t-fast);
  border: 1px solid var(--border);
  z-index: 300;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.login-bg-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
}

.login-bg-glow.glow-1 {
  background: rgba(99, 102, 241, 0.15);
  top: -200px;
  left: -200px;
}

.login-bg-glow.glow-2 {
  background: rgba(139, 92, 246, 0.1);
  bottom: -200px;
  right: -200px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--accent-grad);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 1rem;
  box-shadow: var(--shadow-glow);
}

.login-logo h2 {
  font-size: 22px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .app-header {
    padding: 0 1rem;
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  .builder-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .content-area {
    padding: 1rem;
  }

  .form-row.cols-2,
  .form-row.cols-3 {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrap {
    max-width: 100%;
  }

  .stat-card {
    flex-direction: column;
    text-align: center;
  }
}

.mobile-menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-primary);
}

/* ============================================================
   Utilities
   ============================================================ */
.d-flex {
  display: flex;
}

.d-grid {
  display: grid;
}

.d-none {
  display: none;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

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

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.gap-3 {
  gap: 1.5rem;
}

.flex-1 {
  flex: 1;
}

.w-100 {
  width: 100%;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.p-0 {
  padding: 0 !important;
}

.overflow-hidden {
  overflow: hidden;
}

.position-relative {
  position: relative;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state .empty-icon {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

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

/* ============================================================
   Animations
   ============================================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
  }

  70% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease forwards;
}

.animate-slideUp {
  animation: slideUp 0.35s ease forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.10) 50%, rgba(0, 0, 0, 0.05) 75%);
  background-size: 2000px 100%;
  animation: shimmer 2s linear infinite;
  border-radius: var(--radius-sm);
}

/* Print styles */
@media print {

  .sidebar,
  .app-header,
  .btn-group,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    border: 1px solid #ccc;
  }
}