/* ── Dashboard Layout ──────────────────────────────────────────── */
.dash {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

/* ── Top Navigation ───────────────────────────────────────────── */
.dash-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 50;
}

.dash-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    margin-right: 8px;
}

.dash-nav-links { display: flex; gap: 4px; }

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.15s;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-glow); color: var(--accent-light); }

.dash-nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: var(--text-secondary); }
.btn-logout { font-size: 13px; }

/* ── Dashboard Main (list page) ───────────────────────────────── */
.dash-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 32px;
    width: 100%;
    flex: 1;
    overflow-y: auto;
}

.dash-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}
.dash-header h1 { font-size: 24px; font-weight: 700; }
.dash-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ── Two-Column Page Layout (add/edit) ────────────────────────── */
.page-scroll {
    flex: 1;
    overflow-y: auto;
}

.page-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 32px 64px;
    align-items: start;
}

.page-content {
    min-width: 0;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
}
.page-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.6;
}

.back-link {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: inline-block;
    text-decoration: none;
    transition: color 0.15s;
}
.back-link:hover { color: var(--accent-light); text-decoration: none; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.page-sidebar {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.sidebar-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}
.sidebar-card-icon {
    margin-bottom: 14px;
    opacity: 0.7;
}

.sidebar-steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
}
.sidebar-steps li {
    counter-increment: step;
    position: relative;
    padding-left: 28px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.sidebar-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 1px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent-light);
    font-size: 11px;
    font-weight: 600;
    display: grid;
    place-items: center;
}
.sidebar-steps li:last-child { margin-bottom: 0; }

.sidebar-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.sidebar-tip { border-color: rgba(108, 92, 231, 0.25); }

.sidebar-store-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}
.sidebar-store-preview h3 { margin-bottom: 0; font-size: 16px; }
.preview-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--surface);
    margin-bottom: 4px;
}
.store-logo-placeholder.lg {
    width: 56px;
    height: 56px;
    font-size: 24px;
}
.preview-url {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}
.preview-badge {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 12px;
    margin-top: 4px;
}
.preview-store {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}
.preview-store .preview-logo { width: 48px; height: 48px; }

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-btn { width: 100%; justify-content: center; }

.sidebar-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.meta-row span:first-child { color: var(--text-muted); }
.meta-row code {
    font-size: 12px;
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--accent-light);
}

.sidebar-danger-zone { border-color: rgba(225, 112, 85, 0.25); }
.sidebar-danger-zone h3 { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    color: #fff;
    line-height: 1.4;
}
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-light); color: var(--bg); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); text-decoration: none; }
.btn-success { background: #00b894; }
.btn-success:hover { background: #00d2a4; }
.btn-warning { background: #6c5c00; border-color: #8a7500; }
.btn-warning:hover { background: #8a7500; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 11px 18px; }
.btn-test { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-test:hover { color: var(--accent-light); border-color: var(--accent); }
.btn-lg { padding: 11px 28px; font-size: 15px; }

/* ── Search Bar ───────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 24px;
    transition: border-color 0.15s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-icon { color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-count {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.no-results {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

/* ── Store Cards (dashboard list) ─────────────────────────────── */
.store-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.store-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.store-card:hover { border-color: #555; box-shadow: 0 4px 20px rgba(0,0,0,0.25); }
.store-card.store-inactive { opacity: 0.55; }

.store-card-top { flex: 1; display: flex; flex-direction: column; }

.store-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    gap: 8px;
}

.store-info { display: flex; align-items: center; gap: 12px; min-width: 0; }

.store-logo { width: 38px; height: 38px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.store-logo-placeholder {
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    background: var(--accent-glow); color: var(--accent-light);
    display: grid; place-items: center; font-weight: 700; font-size: 16px;
    flex-shrink: 0;
}

.store-name {
    font-size: 15px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.store-slug { font-size: 11px; color: var(--text-muted); }

.store-status { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.status-active { background: rgba(0, 184, 148, 0.15); color: #00b894; }
.status-inactive { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }

.store-card-body {
    padding: 0 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.store-field label {
    display: block; font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 2px;
}
.store-field code {
    font-size: 12px; color: var(--accent-light); background: var(--bg-tertiary);
    padding: 2px 5px; border-radius: 4px; word-break: break-all;
    display: inline-block; max-width: 100%;
}
.store-field span { font-size: 13px; color: var(--text-secondary); }
.code-sm { font-size: 11px; }

.store-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.store-health {
    display: flex; align-items: center; gap: 6px; font-size: 11px;
    color: var(--text-secondary); padding-top: 8px;
    border-top: 1px solid var(--border); flex-wrap: wrap;
    margin-top: auto;
}
.health-indicator { width: 7px; height: 7px; border-radius: 50%; }
.health-ok { background: #00b894; }
.health-fail { background: var(--danger); }
.health-uptime { margin-left: auto; color: var(--text-muted); }

.store-card-actions {
    display: flex; gap: 6px; padding: 10px 16px;
    border-top: 1px solid var(--border); background: rgba(0, 0, 0, 0.15);
    flex-wrap: wrap;
}

/* ── Test Result ──────────────────────────────────────────────── */
.test-result { padding: 10px 14px; font-size: 13px; border-radius: var(--radius-sm); margin-top: 10px; }
.test-loading { color: var(--text-muted); background: var(--surface); }
.test-success { color: #00b894; background: rgba(0, 184, 148, 0.08); }
.test-fail { color: var(--danger); background: rgba(225, 112, 85, 0.08); }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 56px; color: var(--accent); margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 24px; }

/* ── Form Sections with Left Icons ────────────────────────────── */
.form-section {
    display: flex;
    gap: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}
.form-section:hover { border-color: #444; }

.section-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent-light);
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.success-icon {
    background: rgba(0, 184, 148, 0.15);
    color: #00b894;
}
.dim-icon {
    background: var(--surface);
    color: var(--text-muted);
}

.section-content { flex: 1; min-width: 0; }
.section-content h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.section-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.6;
}

.optional-tag {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 8px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ── Form Groups ──────────────────────────────────────────────── */
.store-form { /* not needed in new layout */ }

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea { resize: vertical; font-family: monospace; font-size: 13px; }

.input-readonly {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-help { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.checkbox-label { display: flex !important; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.form-actions-bar {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 0 0;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.form-errors {
    background: rgba(225, 112, 85, 0.1);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--danger);
}

/* ── Collapsible Sections ─────────────────────────────────────── */
.collapsible .toggle-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    transition: color 0.15s;
}
.collapsible .toggle-header:hover { color: var(--accent-light); }
.toggle-icon { font-size: 18px; color: var(--text-muted); margin-left: auto; width: 24px; text-align: center; }

.section-body { padding-top: 16px; border-top: 1px solid var(--border); margin-top: 14px; }

/* ── Probe ────────────────────────────────────────────────────── */
.probe-row { display: flex; gap: 12px; align-items: flex-end; }
.probe-row .btn { height: 44px; white-space: nowrap; }

.probe-status { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.probe-loading { color: var(--text-muted); background: var(--surface); }
.probe-success { color: #00b894; background: rgba(0, 184, 148, 0.08); border: 1px solid rgba(0, 184, 148, 0.2); }
.probe-fail { color: var(--danger); background: rgba(225, 112, 85, 0.08); border: 1px solid rgba(225, 112, 85, 0.2); }

.detected-section { border-color: rgba(0, 184, 148, 0.3); }

.detected-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}
.detected-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.detected-row h3 { font-size: 18px; font-weight: 600; }
.detected-tagline { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.detected-desc { color: var(--text-secondary); font-size: 13px; margin-bottom: 12px; }
.detected-logo { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface); }
.detected-stats { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.stat { font-size: 13px; color: var(--accent-light); background: var(--accent-glow); padding: 4px 10px; border-radius: 12px; }
.detected-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tag { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--surface); color: var(--text-secondary); }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login Page ───────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 380px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 32px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header .logo-icon { font-size: 36px; color: var(--accent); display: block; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }
.login-error {
    background: rgba(225, 112, 85, 0.1); border: 1px solid var(--danger);
    border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 20px;
    font-size: 14px; color: var(--danger); text-align: center;
}
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { margin-top: 8px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .page-layout {
        grid-template-columns: 1fr;
        padding: 20px 16px 48px;
    }
    .page-sidebar {
        position: static;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        order: -1;
    }
}

/* ── Settings Page ────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: rgba(0, 184, 148, 0.1); border: 1px solid rgba(0, 184, 148, 0.3); color: #00b894; }
.alert-error { background: rgba(225, 112, 85, 0.1); border: 1px solid rgba(225, 112, 85, 0.3); color: var(--danger); }

.key-input-row { display: flex; gap: 8px; }
.key-input-row input { flex: 1; }
.key-input-row .btn { height: 42px; flex-shrink: 0; }

.key-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-top: 8px;
    font-weight: 500;
}
.key-set { color: #00b894; }
.key-missing { color: var(--danger); }

.ai-status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot-ok { background: #00b894; box-shadow: 0 0 8px rgba(0, 184, 148, 0.5); }
.status-dot-off { background: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .store-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-main { padding: 24px 20px; }
}

@media (max-width: 640px) {
    .dash-nav { padding: 0 12px; gap: 8px; }
    .dash-main { padding: 20px 12px; }
    .store-grid { grid-template-columns: 1fr; }
    .form-row, .store-field-row { grid-template-columns: 1fr; }
    .dash-header { flex-direction: column; }
    .page-sidebar { grid-template-columns: 1fr; }
    .form-section { flex-direction: column; gap: 12px; }
    .section-icon { width: 28px; height: 28px; font-size: 12px; }
}
