/* ===== DCMS — Style Sheet ===== */

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

:root {
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-sidebar: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-active: #334155;
  --color-bg: #f1f5f9;
  --color-card: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --sidebar-w: 250px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); color: var(--color-text); background: var(--color-bg); min-height: 100vh; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
body.has-sidebar { display: flex; }
.sidebar { width: var(--sidebar-w); min-height: 100vh; background: var(--color-sidebar); color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; z-index: 100; }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 2rem 2.5rem; min-height: 100vh; width: calc(100% - var(--sidebar-w)); }

/* --- Sidebar --- */
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 1.5rem 1.25rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 38px; height: 38px; background: var(--color-primary); color: #fff; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem; flex-shrink: 0; }
.brand-icon-lg { width: 56px; height: 56px; font-size: 1.6rem; border-radius: var(--radius-lg); }
.brand-name { font-size: 1.1rem; font-weight: 700; color: #f1f5f9; }
.brand-sub { font-size: .75rem; color: #64748b; }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: .65rem 1.25rem; color: #94a3b8; font-size: .9rem; font-weight: 500; transition: background .15s, color .15s; text-decoration: none; }
.nav-link:hover { background: var(--color-sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-link.active { background: var(--color-sidebar-active); color: #fff; }
.nav-link svg { flex-shrink: 0; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding: .75rem 0; }
.sidebar-user { padding: .5rem 1.25rem; display: flex; align-items: center; gap: 8px; }
.user-email { font-size: .8rem; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.nav-logout { color: #ef4444 !important; }
.nav-logout:hover { background: rgba(239,68,68,.1) !important; }

/* --- Auth Layout --- */
body.no-sidebar { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.auth-container { width: 100%; max-width: 420px; padding: 1rem; }
.auth-card { background: var(--color-card); border-radius: var(--radius-lg); padding: 2.5rem 2rem; box-shadow: var(--shadow-md); }
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand h1 { font-size: 1.5rem; margin-top: .75rem; }
.auth-brand p { margin-top: .25rem; }
.auth-form { margin-top: 1.5rem; }
.auth-hint { text-align: center; margin-top: 1.5rem; font-size: .82rem; }
.auth-back { display: inline-block; margin-top: 1.25rem; font-size: .85rem; text-align: center; width: 100%; }

/* --- Page Header --- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* --- Breadcrumb --- */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--color-text-secondary); margin-bottom: 1rem; }
.breadcrumb a { color: var(--color-primary); }
.breadcrumb .sep { color: #cbd5e1; }

/* --- Cards --- */
.card { background: var(--color-card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.75rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.step-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fff;
}
.step-section h3 {
  font-size: 1rem;
  margin-bottom: .85rem;
}
.wizard-steps {
  display: flex;
  gap: .6rem;
  margin-bottom: 1rem;
}
.wizard-step {
  padding: .35rem .7rem;
  border-radius: 999px;
  font-size: .8rem;
  color: var(--color-text-secondary);
  background: #f1f5f9;
}
.wizard-step.active {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

.group-card { display: flex; flex-direction: column; align-items: center; background: var(--color-card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 2rem 1.5rem; text-align: center; transition: box-shadow .2s, transform .15s; text-decoration: none; color: var(--color-text); }
.group-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.group-card-icon { color: var(--color-primary); margin-bottom: .75rem; }
.group-card-name { font-size: 1.05rem; font-weight: 600; }
.group-card-count { font-size: .82rem; color: var(--color-text-secondary); margin-top: .35rem; }

/* --- Tables --- */
.table-wrap { background: var(--color-card); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: .85rem 1.25rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-secondary); background: #f8fafc; border-bottom: 1px solid var(--color-border); font-weight: 600; }
.table td { padding: .85rem 1.25rem; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.td-name { font-weight: 600; }
.th-action, .td-action { text-align: center; width: 70px; }
.build-meta { line-height: 1.35; }
.build-meta .text-muted { font-size: .78rem; }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; font-size: .75rem; font-weight: 600; border-radius: 999px; line-height: 1.4; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-green { background: var(--color-success-bg); color: var(--color-success); }
.badge-red { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-yellow { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-outline { background: transparent; color: var(--color-text-secondary); border: 1px solid var(--color-border); }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: .55rem 1.15rem; font-size: .88rem; font-weight: 600; border: none; border-radius: var(--radius); cursor: pointer; transition: background .15s, opacity .15s; font-family: var(--font); text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: #f1f5f9; color: var(--color-text); }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { background: none; border: none; padding: .4rem; color: var(--color-text-secondary); cursor: pointer; border-radius: var(--radius); }
.btn-icon:hover { background: #f1f5f9; color: var(--color-primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Forms --- */
.form-group { margin-bottom: 1.15rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: var(--color-text); }
.form-control { width: 100%; padding: .6rem .85rem; font-size: .9rem; border: 1.5px solid var(--color-border); border-radius: var(--radius); background: #fff; color: var(--color-text); font-family: var(--font); transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-control:disabled { background: #f8fafc; color: #94a3b8; cursor: not-allowed; }
.form-control::placeholder { color: #94a3b8; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: .78rem; color: var(--color-text-secondary); margin-top: .25rem; display: block; }
.form-actions-inline { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.form-hint-inline { font-size: .8rem; color: var(--color-text-secondary); }
.form-hint-inline.success { color: var(--color-success); font-weight: 600; }
.form-hint-inline.warning { color: var(--color-warning); }
.form-hint-inline.error { color: var(--color-danger); }
.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border); }
.form-actions-right { display: flex; gap: .5rem; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: .9rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.pull-update-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: .9rem 1rem;
  margin-bottom: 1rem;
}

.pull-update-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.pull-update-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--color-text);
}

.pull-update-sub {
  font-size: .8rem;
  color: var(--color-text-secondary);
  margin-top: .15rem;
}

.pull-update-hint {
  margin-top: .65rem;
  font-size: .8rem;
  color: var(--color-text-secondary);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background .2s ease;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .2s ease;
}

.switch input:checked + .switch-track {
  background: var(--color-primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  min-width: 28px;
}

.pin-input { text-align: center; font-size: 2rem; letter-spacing: .4em; font-weight: 700; padding: .75rem; }

.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: #e2e8f0; color: #475569; font-size: .7rem; font-weight: 700; cursor: help; margin-left: 4px; vertical-align: middle; }

/* --- Project Selector --- */
.project-selector { border: 1.5px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.project-selector .form-control { border: none; border-bottom: 1px solid var(--color-border); border-radius: 0; }
.project-list { max-height: 180px; overflow-y: auto; padding: .5rem .75rem; }
.project-item { padding: .3rem 0; }

/* --- Alerts --- */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .87rem; margin-top: 1rem; }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }

.update-log-box {
  margin-top: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 400;
  min-width: 180px;
  max-width: 340px;
  padding: .7rem .95rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: .88rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

/* --- Modals --- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--color-card); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-sm { max-width: 420px; }
.modal-validation { max-width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem .75rem; }
.modal-header h2 { font-size: 1.15rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.5rem; color: var(--color-text-secondary); cursor: pointer; padding: 0 .25rem; line-height: 1; }
.modal-close:hover { color: var(--color-text); }
.modal-body { padding: .75rem 1.5rem; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem 1.25rem; gap: .5rem; }
.modal-footer > div { display: flex; gap: .5rem; }
.modal-footer .btn:only-child { margin-left: auto; }

/* --- Validation Steps --- */
.validation-intro {
  font-size: .88rem;
  color: var(--color-text-secondary);
  margin-bottom: .75rem;
}
.validation-steps { display: flex; flex-direction: column; gap: .75rem; }
.validation-step {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  padding: .85rem .95rem;
  border-radius: var(--radius);
}
.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-icon { font-size: 1.1rem; flex-shrink: 0; width: 24px; text-align: center; }
.step-pending { color: #94a3b8; }
.step-checking { color: var(--color-primary); animation: pulse .8s infinite; }
.step-passed { color: var(--color-success); }
.step-failed { color: var(--color-danger); }
.step-label { font-weight: 700; font-size: .95rem; }
.step-state {
  margin-left: auto;
  font-size: .75rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  padding: .18rem .52rem;
  border-radius: 999px;
  background: #e2e8f0;
}
.step-message {
  font-size: .86rem;
  color: var(--color-text-secondary);
  margin-top: .35rem;
  margin-left: 34px;
  line-height: 1.45;
}
.step-details {
  margin-left: 52px;
  margin-top: .35rem;
  color: var(--color-text-secondary);
  font-size: .8rem;
  line-height: 1.45;
}
.step-details li {
  margin-bottom: .15rem;
}

.validation-step[data-status="checking"] .step-state {
  background: #dbeafe;
  color: #1d4ed8;
}

.validation-step[data-status="passed"] {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.validation-step[data-status="passed"] .step-state {
  background: #dcfce7;
  color: #15803d;
}

.validation-step[data-status="failed"] {
  border-color: #fecaca;
  background: #fef2f2;
}

.validation-step[data-status="failed"] .step-state {
  background: #fee2e2;
  color: #b91c1c;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--color-text-secondary); }
.empty-state svg { margin-bottom: 1rem; }
.empty-state h3 { color: var(--color-text); margin-bottom: .5rem; }

/* --- Utility --- */
.text-muted { color: var(--color-text-secondary); }
.text-danger { color: var(--color-danger); }

/* --- Responsive --- */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1.25rem; width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
