/* cardly-admin.css — ADMIN face, migrated onto the Cardly Feel design tokens (cardly-base.css).
   Loads AFTER cardly-base.css. The :root overrides below give ADMIN its own DPStudio-blue accent
   and slate chrome; everything else rides the shared token scale (surface/ink/line/radius/shadow/
   space/font). Semantic button/tag/status colours stay explicit — they must read exactly. */
:root {
    --brand-primary: #2563eb;            /* ADMIN accent: links, active tab, focus, primary button */
    --admin-sidebar: #1f2937;            /* dark slate chrome — ADMIN identity, no base-token twin */
    --admin-sidebar-active: #111827;
    --admin-sidebar-ink: #d1d5db;
    --admin-accent-line: #3b82f6;
}

* { box-sizing: border-box; }
body {
    font-family: var(--font-ui);
    margin: 0; background: var(--surface-2); color: var(--ink);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; background: var(--admin-sidebar); color: #f9fafb;
    padding: var(--space-4) 0; flex-shrink: 0;
    display: flex; flex-direction: column;
}
.sidebar h1 { font-size: var(--text-lg); padding: 0 var(--space-4); margin: 0 0 var(--space-5); }
.sidebar nav a {
    display: block; padding: 10px var(--space-4); color: var(--admin-sidebar-ink);
    border-left: 3px solid transparent;
}
.sidebar nav a.active, .sidebar nav a:hover {
    background: var(--admin-sidebar-active); color: #fff;
    border-left-color: var(--admin-accent-line); text-decoration: none;
}
.sidebar nav a.disabled { color: var(--ink-2); pointer-events: none; }
.main { flex: 1; padding: var(--space-5) var(--space-6); overflow-x: auto; }
.main h2 { margin-top: 0; }

.btn {
    display: inline-block; padding: var(--space-2) var(--space-4); background: var(--brand);
    color: var(--brand-on); border: 0; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 14px;
}
.btn:hover { background: var(--brand-hover); }
.btn.secondary { background: #6b7280; color: #fff; }
.btn.secondary:hover { background: #4b5563; }
.btn.success { background: #16a34a; color: #fff; }
.btn.success:hover { background: #15803d; }
.btn.danger { background: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
/* Hyphenated variants for the shared CardlyUI modals (buildModal emits btn-primary/
   btn-secondary/btn-danger); ADMIN's own buttons use the compound .btn.danger form.
   Map both to the same palette so kit confirm/prompt/alert dialogs read correctly here. */
.btn-primary   { background: var(--brand); color: var(--brand-on); }
.btn-primary:hover   { background: var(--brand-hover); }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover    { background: #b91c1c; }

/* Icon-only action button: used in table action columns. Same class for ALL buttons
   in an action group; distinguish by icon shape, never by color. */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--ink);
    border: 1px solid #9ca3af;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    font-size: var(--text-sm);
    transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.btn-icon:hover { background: var(--ink); color: #fff; border-color: var(--ink); text-decoration: none; }
.btn-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-icon-group { display: inline-flex; gap: var(--space-1); flex-wrap: nowrap; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td {
    padding: 10px var(--space-3); text-align: left;
    border-bottom: 1px solid var(--line);
}
.table th { background: var(--surface-2); font-weight: 600; }
.table tr:hover { background: var(--surface-2); }

/* Compact columns: actions, codes, dates, single-badge — width 1% + nowrap so they shrink to content */
.table .col-actions, .table .col-compact {
    width: 1%;
    white-space: nowrap;
}

.form-row { margin-bottom: var(--space-4); }
.form-row label {
    display: block; margin-bottom: var(--space-1);
    font-size: var(--text-sm); color: var(--ink);
}
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--ink);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: var(--brand);
}

/* Form grid: pack short fields 2-3 per row on wide screens */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-3) var(--space-5);
    margin-bottom: var(--space-4);
}
.form-grid .form-row { margin-bottom: 0; }
.form-grid .form-row.span-2 { grid-column: span 2; }
.form-grid .form-row.span-full { grid-column: 1 / -1; }

/* Section divider inside a form */
.form-section { margin: var(--space-5) 0 var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section h3 { margin: 0 0 var(--space-3); font-size: var(--text-md); color: var(--ink); font-weight: 600; }

/* Inline checkbox: label sits to the right of the input */
.form-checkbox {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) 0;
}
.form-checkbox input[type="checkbox"] {
    width: 18px; height: 18px; margin: 0; cursor: pointer; flex-shrink: 0;
}
.form-checkbox label {
    display: inline; margin: 0; cursor: pointer;
    font-size: 14px; color: var(--ink);
}

/* Logo uploader: preview + pick/drop + remove */
.logo-uploader {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--space-4);
    align-items: start;
    padding: var(--space-4);
    border: 2px dashed var(--line);
    border-radius: var(--radius-md);
    transition: border-color var(--dur-base), background var(--dur-base);
}
.logo-uploader.dragover { border-color: var(--brand); background: var(--brand-tint-1); }
.logo-preview {
    width: 200px; height: 140px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-placeholder { color: var(--ink-2); font-size: var(--text-sm); text-align: center; padding: var(--space-2); }
.logo-controls { display: flex; flex-direction: column; gap: var(--space-2); }
.logo-controls .btn { align-self: flex-start; }
.logo-hint { color: var(--ink-2); font-size: var(--text-xs); line-height: 1.4; }

/* Color picker row: native swatch + hex code displayed */
.color-row { display: flex; align-items: center; gap: var(--space-3); }
.color-row input[type="color"] {
    width: 56px; height: 36px; padding: 2px;
    border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface);
}
.color-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
.color-row input[type="color"]::-moz-color-swatch { border: 0; border-radius: 2px; }
.color-row .color-hex {
    font-family: ui-monospace, monospace; font-size: var(--text-sm); color: var(--ink-2);
    text-transform: uppercase;
}

.card {
    background: var(--surface); padding: var(--space-5); border-radius: var(--radius-md);
    box-shadow: var(--shadow-1); margin-bottom: var(--space-4);
}

.toast {
    position: fixed; bottom: var(--space-5); right: var(--space-5);
    padding: var(--space-3) var(--space-5); background: #111827; color: #fff;
    border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
    opacity: 0; transition: opacity var(--dur-base);
    z-index: 1000;
}
.toast.show { opacity: 1; }
.toast.error { background: #dc2626; }
.toast.success { background: #16a34a; }

.tag {
    display: inline-block; padding: 2px var(--space-2);
    border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 600;
}
.tag.active     { background: #dcfce7; color: #15803d; }
.tag.suspended  { background: #fef3c7; color: #b45309; }
.tag.archived   { background: #e5e7eb; color: #4b5563; }
.tag.disabled   { background: #fee2e2; color: #b91c1c; }

.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--line); margin-bottom: var(--space-4); }
.tabs a {
    padding: var(--space-3) var(--space-5); color: var(--ink-2); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a.disabled { color: var(--ink-2); pointer-events: none; }

.empty {
    padding: var(--space-7); text-align: center; color: var(--ink-2);
    background: var(--surface); border-radius: var(--radius-md);
}
