/* public/css/app.css — Workout Tracker */

:root {
  --bg:        #0f1117;
  --bg2:       #181c26;
  --bg3:       #1e2333;
  --border:    #2a3148;
  --accent:    #3d7bff;
  --accent2:   #2a60e0;
  --green:     #22c55e;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --text:      #e4e8f0;
  --muted:     #8892a8;
  --radius:    10px;
  --sidebar-w: 220px;
  --font:      'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo a {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .3px;
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-logo .logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

nav { padding: 10px 0; flex: 1; }
.nav-section { padding: 10px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(61,123,255,.07); text-decoration: none; }
.nav-item.active { color: var(--accent); background: rgba(61,123,255,.12); border-left-color: var(--accent); }
.nav-item .nav-icon { width: 16px; text-align: center; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.sidebar-footer .user-name { font-weight: 600; color: var(--text); font-size: 13px; }
.sidebar-footer .user-role { opacity: .7; }
.sidebar-footer a { color: var(--muted); font-size: 12px; }
.sidebar-footer a:hover { color: var(--red); }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-body { padding: 24px 28px; flex: 1; }

/* ── Flash ──────────────────────────────────────────────── */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.flash-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }
.flash-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #f87171; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px;
}
.card-body { padding: 18px; }

/* ── Stat cards ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-icon { font-size: 22px; margin-bottom: 8px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  border: none; cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; color: var(--text); }
.btn-danger    { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: rgba(239,68,68,.2); text-decoration: none; color: #f87171; }
.btn-success   { background: rgba(34,197,94,.12); color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { border-bottom: 1px solid var(--border); }
th { padding: 10px 12px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px;
  font-family: var(--font);
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--muted); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}
.badge-blue   { background: rgba(61,123,255,.15); color: #7ba8ff; border: 1px solid rgba(61,123,255,.2); }
.badge-green  { background: rgba(34,197,94,.12); color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.badge-amber  { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.badge-gray   { background: rgba(255,255,255,.06); color: var(--muted); border: 1px solid var(--border); }
.badge-red    { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.2); }

/* ── Search bar ──────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { max-width: 320px; }

/* ── Player / Exercise cards ─────────────────────────────── */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.entity-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s;
}
.entity-card:hover { border-color: var(--accent); }
.entity-card .ec-img {
  height: 140px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  overflow: hidden;
}
.entity-card .ec-img img { width: 100%; height: 100%; object-fit: cover; }
.entity-card .ec-body { padding: 10px 12px; }
.entity-card .ec-name { font-size: 13px; font-weight: 600; color: var(--text); }
.entity-card .ec-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.entity-card .ec-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ── Program builder ─────────────────────────────────────── */
.builder { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.days-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.day-tab {
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.day-tab:hover  { color: var(--text); border-color: var(--accent); }
.day-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.section-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.section-header {
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px;
}
.section-header input {
  background: transparent; border: none; color: var(--text);
  font-weight: 600; font-size: 13px; padding: 0; width: auto; flex: 1;
}
.section-header input:focus { outline: none; border-bottom: 1px dashed var(--accent); }

.ex-row {
  display: grid;
  grid-template-columns: 28px 28px 1fr 80px 60px auto;
  gap: 8px; padding: 8px 14px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.ex-row:last-child { border-bottom: none; }
.ex-row .ex-thumb { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-size: 14px; overflow: hidden; }
.ex-row .ex-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ex-row .ex-name { font-size: 13px; }
.ex-row .ex-tag  { font-size: 11px; color: var(--muted); }
.ex-row .ex-sets { font-size: 12px; color: var(--muted); }
.ex-row.drag-over { background: rgba(61,123,255,.08); }
.ex-row[draggable] { cursor: grab; }

.ex-add-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; color: var(--muted); font-size: 12px;
  cursor: pointer; transition: color .15s;
  border-top: 1px dashed var(--border);
}
.ex-add-btn:hover { color: var(--accent); }

/* ── Exercise search panel ───────────────────────────────── */
.ex-search-results {
  position: absolute; z-index: 200;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); max-height: 260px; overflow-y: auto;
  width: 100%; top: 100%; left: 0; box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.ex-search-item {
  padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: background .1s;
}
.ex-search-item:hover { background: var(--bg3); }
.ex-search-item img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }
.ex-search-item .esi-name { font-size: 13px; }
.ex-search-item .esi-cat  { font-size: 11px; color: var(--muted); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 560px; max-width: calc(100vw - 32px);
  max-height: 90vh; overflow-y: auto;
  padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title  { font-size: 16px; font-weight: 700; }
.modal-close  { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── View program ────────────────────────────────────────── */
.program-day-section {
  margin-bottom: 24px;
}
.program-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); font-weight: 700; margin-bottom: 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.program-ex-table { width: 100%; border-collapse: collapse; }
.program-ex-table th { font-size: 10px; text-transform: uppercase; color: var(--muted); padding: 4px 8px; text-align: left; }
.program-ex-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.program-ex-table .ex-img-cell img { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; }
.program-ex-table .ex-img-cell .placeholder { width: 36px; height: 36px; border-radius: 4px; background: var(--bg3); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }

/* ── Login ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 30%, rgba(61,123,255,.08) 0%, transparent 60%), var(--bg);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
  width: 380px; max-width: calc(100vw - 32px);
}
.login-box .login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-box .login-logo .icon {
  width: 52px; height: 52px; background: var(--accent);
  border-radius: 14px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.login-box .login-logo h1 { font-size: 20px; font-weight: 700; }
.login-box .login-logo p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.login-box .form-group { margin-bottom: 14px; }
.login-box .btn-primary { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .builder { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .page-body { padding: 16px; }
}

/* ── Misc ────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
