/* ==========================================================================
   Automation Practice — Global Styles
   ========================================================================== */
:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #475569;
  --muted: #94a3b8;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(2, 6, 23, 0.08);
  --shadow-lg: 0 20px 40px rgba(2, 6, 23, 0.18);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--bg);
  color: #cbd5e1;
  padding: 20px 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar .brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  padding: 0 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 10px;
}
.sidebar .brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary);
}
.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.sidebar nav a.active {
  background: rgba(79,70,229,.15);
  border-left-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.sidebar .nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 14px 20px 6px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .crumb { font-size: 14px; color: var(--text-soft); }
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
}
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

.content { padding: 28px 24px; max-width: 1100px; width: 100%; }

.page-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--text-soft); margin: 0 0 24px; }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.card h2 { font-size: 18px; margin: 0 0 4px; }
.card .hint { font-size: 13px; color: var(--muted); margin: 0 0 18px; }

.grid { display: grid; gap: 22px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); }
.field .req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="url"], input[type="search"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"],
input[type="week"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
textarea { min-height: 90px; resize: vertical; }

input.invalid, textarea.invalid, select.invalid { border-color: var(--danger); }
.field .error-msg { color: var(--danger); font-size: 12px; margin-top: 5px; display: none; }
.field .error-msg.show { display: block; }

.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.check-row input { width: auto; }
.check-row label { margin: 0; font-weight: 400; color: var(--text); }

.inline-fields { display: flex; gap: 14px; flex-wrap: wrap; }
.inline-fields .field { flex: 1; min-width: 160px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .05s;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.warning { background: var(--warning); }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Badges / alerts ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.gray { background: #e2e8f0; color: #334155; }

.alert {
  padding: 12px 16px; border-radius: 8px; font-size: 14px;
  margin-bottom: 16px; border: 1px solid transparent;
  display: flex; align-items: center; gap: 10px;
}
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------- Tables ---------- */
table.data {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.data th, table.data td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.data th {
  background: var(--surface-2); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-soft); cursor: pointer; user-select: none;
}
table.data th.sortable:hover { color: var(--primary); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td .actions { display: flex; gap: 6px; }

.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 14px; }
.pagination button {
  padding: 6px 11px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(2,6,23,.55);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; overflow: hidden;
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg); color: #fff; padding: 12px 16px; border-radius: 8px;
  box-shadow: var(--shadow-lg); font-size: 14px; min-width: 240px;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .2s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Spinner / loader ---------- */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner.lg { width: 40px; height: 40px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { display: flex; align-items: center; gap: 12px; color: var(--text-soft); padding: 20px; justify-content: center; }

.progress { background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
  border-radius: 6px; height: 14px; margin-bottom: 10px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs .tab {
  padding: 10px 16px; cursor: pointer; font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; color: var(--text-soft);
}
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Accordion ---------- */
.accordion-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.accordion-head {
  padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; background: var(--surface);
}
.accordion-head:hover { background: var(--surface-2); }
.accordion-body { padding: 0 16px; max-height: 0; overflow: hidden; transition: max-height .25s ease, padding .25s ease; font-size: 14px; color: var(--text-soft); }
.accordion-item.open .accordion-body { max-height: 300px; padding: 0 16px 16px; }
.accordion-head .chev { transition: transform .2s; }
.accordion-item.open .accordion-head .chev { transform: rotate(180deg); }

/* ---------- Tooltip ---------- */
.tooltip { position: relative; display: inline-block; border-bottom: 1px dotted var(--muted); cursor: help; }
.tooltip .tip {
  visibility: hidden; opacity: 0; position: absolute; bottom: 130%; left: 50%;
  transform: translateX(-50%); background: var(--bg); color: #fff; padding: 6px 10px;
  border-radius: 6px; font-size: 12px; white-space: nowrap; transition: opacity .15s; z-index: 30;
}
.tooltip:hover .tip { visibility: visible; opacity: 1; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; top: 110%; left: 0; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 30; overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 10px 14px; font-size: 14px; color: var(--text); }
.dropdown-menu a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Drag & drop ---------- */
.dnd-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dnd-col { background: var(--surface-2); border-radius: 10px; padding: 14px; min-height: 220px; }
.dnd-col h4 { margin: 0 0 12px; font-size: 14px; }
.dnd-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: grab; font-size: 14px;
}
.dnd-item.dragging { opacity: .4; }
.dnd-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 36px;
  text-align: center; color: var(--text-soft); transition: all .15s; cursor: pointer;
}
.dropzone.drag-over { border-color: var(--primary); background: rgba(79,70,229,.05); }

/* ---------- Misc ---------- */
.kv { display: flex; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.kv .k { color: var(--muted); min-width: 120px; }
.code {
  font-family: "Consolas", "Courier New", monospace; font-size: 13px;
  background: var(--bg); color: #e2e8f0; padding: 2px 7px; border-radius: 5px;
}
.testid-tag {
  font-family: "Consolas", monospace; font-size: 11px; color: var(--info);
  background: #ecfeff; padding: 1px 6px; border-radius: 4px; margin-left: 6px;
}
.result-box {
  background: var(--bg); color: #e2e8f0; border-radius: 8px; padding: 14px;
  font-family: "Consolas", monospace; font-size: 13px; white-space: pre-wrap;
  margin-top: 14px; max-height: 300px; overflow: auto;
}
.hero {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; border-radius: 14px; padding: 32px; margin-bottom: 26px;
}
.hero h1 { margin: 0 0 8px; font-size: 28px; }
.hero p { margin: 0; opacity: .9; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
  display: block; color: var(--text);
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; }
.feature-card .ico { font-size: 24px; margin-bottom: 10px; }
.feature-card h3 { margin: 0 0 6px; font-size: 16px; }
.feature-card p { margin: 0; font-size: 13px; color: var(--text-soft); }

.hidden { display: none !important; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.text-muted { color: var(--muted); }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; transition: left .2s; z-index: 50; }
  .sidebar.open { left: 0; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .dnd-wrap { grid-template-columns: 1fr; }
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }
@media (max-width: 860px) { .menu-toggle { display: block; } }
