/* ═══════════════════════════════════════════════════════════════
   CivilPro — UI Components
   ═══════════════════════════════════════════════════════════════ */

/* ═══════ BUTTONS ═══════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--t);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--grad-blue);
  color: #fff;
  box-shadow: 0 2px 8px var(--blue-glow);
}
.btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 4px 16px var(--blue-glow);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--blue-light);
  border-color: var(--blue);
}
.btn-outline:hover {
  background: var(--blue-surface);
}

/* Success */
.btn-success {
  background: var(--grad-success);
  color: #fff;
  box-shadow: 0 2px 8px var(--success-glow);
}
.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Danger */
.btn-danger {
  background: var(--grad-danger);
  color: #fff;
  box-shadow: 0 2px 8px var(--danger-glow);
}
.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Amber */
.btn-amber {
  background: var(--grad-amber);
  color: #000;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--amber-glow);
}
.btn-amber:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Sizes */
.btn-xs { padding: 5px 10px; font-size: 0.75rem; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem;  }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

/* Icon only */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-sm);
}
.btn-icon.btn-sm { width: 30px; height: 30px; }

/* ═══════ CARDS ═══════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  transition: border-color var(--t), box-shadow var(--t);
}

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

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.card-title svg { width: 16px; height: 16px; color: var(--blue); }

.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Sub card */
.card-sm {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
}

/* ═══════ KPI CARD ═══════ */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: all var(--t);
}

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

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color, var(--grad-blue));
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1;
  margin-bottom: 10px;
  overflow: hidden;
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-full);
}
.kpi-change.up   { background: var(--success-glow); color: var(--success); }
.kpi-change.down { background: var(--danger-glow);  color: var(--danger);  }
.kpi-change svg  { width: 12px; height: 12px; }

.kpi-icon-wrapper {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-bg, var(--blue-surface));
}
.kpi-icon-wrapper svg { width: 20px; height: 20px; color: var(--icon-color, var(--blue)); }

/* ═══════ BADGES ═══════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

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

.badge-blue    { background: var(--blue-surface);   color: var(--blue-light); }
.badge-amber   { background: var(--amber-glow);     color: var(--amber-light); }
.badge-success { background: var(--success-glow);   color: var(--success); }
.badge-danger  { background: var(--danger-glow);    color: var(--danger); }
.badge-warning { background: var(--warning-glow);   color: var(--warning); }
.badge-info    { background: var(--info-glow);      color: var(--info); }
.badge-purple  { background: var(--purple-glow);    color: var(--purple); }
.badge-gray    { background: rgba(148,163,184,0.12); color: var(--text-secondary); }

/* ═══════ INPUTS & FORM ═══════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  transition: all var(--t);
  width: 100%;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

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

.form-control option {
  background: var(--bg-card);
  color: var(--text-primary);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

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

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 2px;
}

/* Input with icon */
.input-group {
  position: relative;
}

.input-group .form-control {
  padding-left: 36px;
}

.input-group .input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.input-group-append {
  position: relative;
  display: flex;
}

.input-group-append .form-control {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  flex: 1;
}

.input-group-append .input-append-btn {
  padding: 9px 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--t);
  white-space: nowrap;
  font-family: inherit;
}

.input-group-append .input-append-btn:hover {
  background: var(--blue-surface);
  color: var(--blue-light);
}

/* ═══════ TABLES ═══════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th:first-child { border-radius: var(--r-sm) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--r-sm) 0 0; }

.data-table td {
  padding: 12px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

.data-table td strong {
  color: var(--text-primary);
  font-weight: 600;
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ═══════ TABS ═══════ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
  flex-wrap: wrap;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--r-sm);
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--t);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: transparent;
}

.tab-btn svg { width: 14px; height: 14px; }

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

.tab-btn.active {
  background: var(--blue-surface);
  color: var(--blue-light);
  font-weight: 600;
}

/* ═══════ MODAL ═══════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeInFast 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.25s ease;
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title svg { width: 18px; height: 18px; color: var(--blue); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--danger-glow); color: var(--danger); border-color: var(--danger); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ═══════ PROGRESS BAR ═══════ */
.progress-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--grad-blue);
  transition: width 0.5s ease;
}

.progress-fill.success { background: var(--grad-success); }
.progress-fill.warning { background: var(--grad-amber); }
.progress-fill.danger  { background: var(--grad-danger); }

/* ═══════ DROPDOWN / SELECT ═══════ */
.select-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a5a75' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ═══════ NOTIFICATIONS / ALERTS ═══════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  border-left: 3px solid;
  font-size: 0.85rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--info-glow);    border-color: var(--info);    color: var(--info); }
.alert-success { background: var(--success-glow); border-color: var(--success); color: var(--success); }
.alert-warning { background: var(--warning-glow); border-color: var(--warning); color: var(--warning); }
.alert-danger  { background: var(--danger-glow);  border-color: var(--danger);  color: var(--danger); }

/* ═══════ TOOLTIP ═══════ */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e2d4a;
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t);
  border: 1px solid var(--border-light);
  z-index: 200;
}
[data-tooltip]:hover::after {
  opacity: 1;
}

/* ═══════ STAT ROW ═══════ */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .stat-label { color: var(--text-secondary); }
.stat-row .stat-value { color: var(--text-primary); font-weight: 600; }

/* ═══════ SEARCH BOX ═══════ */
.search-box {
  position: relative;
  flex: 1;
}
.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.search-box .form-control {
  padding-left: 34px;
}

/* ═══════ TIMELINE ═══════ */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 20px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--bg-base);
}
.timeline-date { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 4px; }
.timeline-title { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.timeline-desc { font-size: 0.83rem; color: var(--text-secondary); margin-top: 2px; }

/* ═══════ CHART CONTAINER ═══════ */
.chart-container {
  position: relative;
  width: 100%;
}

/* ═══════ TOAST NOTIFICATIONS ═══════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: all;
  animation: slideInRight 0.3s ease;
  min-width: 280px;
  max-width: 380px;
}

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--success); }
.toast.success svg { color: var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.error svg { color: var(--danger); }
.toast.info    { border-left: 3px solid var(--blue);    }
.toast.info svg { color: var(--blue); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.warning svg { color: var(--warning); }
