/*
 * CloudWizard Controller — Admin Stylesheet
 * Location: {install}/admin/style.css
 *
 * Foundation: Pure.css base (loaded separately as pure.min.css)
 * This file: CloudWizard-specific tokens, components, and layout
 */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    --bg:          #e1e4e9;
    --surface:     #ffffff;
    --border:      #e4e6e9;
    --text:        #1a1d21;
    --sub:         #6b7280;
    --accent:      #2d5a8e;
    --accent-lt:   #e8eef6;
    --green:       #1a7a4a;
    --green-lt:    #e6f4ed;
    --red:         #c0392b;
    --red-lt:      #fdf0ee;
    --amber:       #92600a;
    --amber-lt:    #fef7e6;
    --radius:      8px;
    --shadow:      0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
}

/* ── Reset / base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
}

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

/* ── Top bar ────────────────────────────────────────────────────────────── */
.cw-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.cw-topbar-brand {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -.01em;
}

.cw-topbar-brand span {
    color: var(--accent);
}

.cw-topbar-suite {
    font-weight: 400;
    font-size: 13px;
    color: var(--sub);
    letter-spacing: 0;
}

.cw-topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cw-topbar-nav a {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--sub);
    transition: background .15s, color .15s;
}

.cw-topbar-nav a:hover,
.cw-topbar-nav a.active {
    background: var(--accent-lt);
    color: var(--accent);
    text-decoration: none;
}

.cw-topbar-nav a.cw-nav-missing {
    color: #c0c4cb;
    cursor: default;
}

.cw-topbar-nav a.cw-nav-missing:hover {
    background: none;
    color: #c0c4cb;
}

/* ── Page layout ────────────────────────────────────────────────────────── */
.cw-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

.cw-page-header {
    margin-bottom: 24px;
}

.cw-page-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -.02em;
}

.cw-page-sub {
    color: var(--sub);
    font-size: 13px;
    margin: 0;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.cw-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.cw-card-head {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sub);
}

.cw-card-body {
    padding: 18px;
}

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.cw-stats-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cw-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    flex: 1;
    min-width: 120px;
    max-width: 180px;
}

.cw-stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sub);
    margin-bottom: 6px;
}

.cw-stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--text);
}

.cw-stat-sub {
    font-size: 11px;
    color: var(--sub);
    margin-top: 4px;
}

/* ── Module grid (dashboard 2×2) ────────────────────────────────────────── */
.cw-module-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.cw-module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.cw-module-card.installed {
    border-left: 3px solid var(--accent);
}

.cw-module-card.missing {
    border-left: 3px solid var(--border);
    opacity: .7;
}

.cw-module-card-info {}

.cw-module-card-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 2px;
}

.cw-module-card-version {
    font-size: 11px;
    color: var(--sub);
}

.cw-module-card-action {
    white-space: nowrap;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
    transition: background .15s;
}

.cw-module-card-action.open {
    background: var(--accent-lt);
    color: var(--accent);
}

.cw-module-card-action.open:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.cw-module-card-action.get {
    background: var(--bg);
    color: var(--sub);
    border: 1px solid var(--border);
}

.cw-module-card-action.get:hover {
    background: var(--border);
    text-decoration: none;
}

/* ── Grid layout ────────────────────────────────────────────────────────── */
.cw-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.cw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.cw-table th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sub);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    background: #fafbfc;
}

.cw-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.cw-table tr:last-child td { border-bottom: none; }
.cw-table tr:hover td { background: #fafbfc; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.cw-form-section {
    margin-bottom: 28px;
}

.cw-form-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.cw-form-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    align-items: start;
    gap: 12px;
    margin-bottom: 14px;
}

.cw-form-label {
    font-size: 13px;
    font-weight: 600;
    padding-top: 8px;
    color: var(--text);
}

.cw-form-sub {
    font-size: 11px;
    color: var(--sub);
    margin-top: 2px;
    font-weight: 400;
}

.cw-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}

.cw-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-lt);
}

.cw-input-sm { max-width: 120px; }
.cw-input-md { max-width: 240px; }

select.cw-input { cursor: pointer; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.cw-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, color .15s;
    font-family: inherit;
    text-decoration: none;
}

.cw-btn-primary {
    background: var(--accent);
    color: #fff;
}

.cw-btn-primary:hover {
    background: #244d7a;
    text-decoration: none;
    color: #fff;
}

.cw-btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.cw-btn-secondary:hover {
    background: var(--bg);
    text-decoration: none;
    color: var(--text);
}

.cw-btn-danger {
    background: var(--red-lt);
    color: var(--red);
}

.cw-btn-danger:hover {
    background: var(--red);
    color: #fff;
    text-decoration: none;
}

/* ── Notices ────────────────────────────────────────────────────────────── */
.cw-notice {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.cw-notice-ok     { background: var(--green-lt);  color: var(--green);  border: 1px solid #b7e4cd; }
.cw-notice-warn   { background: var(--amber-lt);  color: var(--amber);  border: 1px solid #f5d6a0; }
.cw-notice-error  { background: var(--red-lt);    color: var(--red);    border: 1px solid #f0b8b1; }
.cw-notice-info   { background: var(--accent-lt); color: var(--accent); border: 1px solid #bcd1eb; }

/* ── Status badges ──────────────────────────────────────────────────────── */
.cw-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.cw-badge-green  { background: var(--green-lt);  color: var(--green);  }
.cw-badge-red    { background: var(--red-lt);    color: var(--red);    }
.cw-badge-amber  { background: var(--amber-lt);  color: var(--amber);  }
.cw-badge-grey   { background: var(--bg);        color: var(--sub);    }
.cw-badge-blue   { background: var(--accent-lt);  color: var(--accent); }

/* ── Progress bar ───────────────────────────────────────────────────────── */
.cw-progress-wrap {
    background: var(--border);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
}

.cw-progress-bar {
    background: var(--accent);
    height: 100%;
    border-radius: 20px;
    transition: width .3s ease;
}

.cw-progress-bar.complete { background: var(--green); }

/* ── Utility ────────────────────────────────────────────────────────────── */
.cw-sub  { color: var(--sub); font-size: 12px; }
.cw-mono { font-family: 'SF Mono', 'Fira Code', Consolas, monospace; font-size: 12px; }
.cw-mt   { margin-top: 14px; }
.cw-mb   { margin-bottom: 14px; }
.cw-right { text-align: right; }

/* ── Responsive (stats exception per ADR §9.3) ──────────────────────────── */
@media (max-width: 700px) {
    .cw-module-grid { grid-template-columns: 1fr; }
    .cw-grid-2 { grid-template-columns: 1fr; }
    .cw-form-row { grid-template-columns: 1fr; }
    .cw-stats-row .cw-stat { min-width: calc(50% - 7px); }
}

/* ── Compact dashboard widget variants ─────────────────────────────────── */
.cw-card-head-tight { padding: 8px 18px; }
.cw-card-body-tight  { padding: 12px 18px; }
.cw-stats-row-tight  { margin-bottom: 10px; gap: 10px; }
.cw-stat-tight        { padding: 10px 14px; }
.cw-stat-tight .cw-stat-value { font-size: 20px; }


/* ── Module card variants ──────────────────────────────────────────────── */
.cw-module-card-wide { grid-column: 1 / -1; }
.cw-module-card-stat {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-top: 4px;
}

/* ── Editor header bar (back button + page title) ──────────────────────── */
.cw-editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.cw-editor-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ── Module sub-nav ─────────────────────────────────────────────────────── */
.cw-subnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 0;
}

.cw-subnav-module {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    padding: 0 20px 0 0;
    margin-right: 4px;
    white-space: nowrap;
    line-height: 44px;
    letter-spacing: -.01em;
}

.cw-subnav a {
    padding: 0 14px;
    line-height: 44px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sub);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.cw-subnav a:hover { color: var(--accent); }
.cw-subnav a.active { color: var(--accent); border-bottom-color: var(--accent); }