/* Spin3D Catalog Editor - Stylesheet
 * Color variables match src/Spin3D.DemoApp/css/styles.css for visual consistency.
 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --primary:      #007bff;
    --primary-dark: #0056b3;
    --error:        #dc3545;
    --error-bg:     #fff5f5;
    --success:      #28a745;
    --border:       #dee2e6;
    --bg-light:     #f8f9fa;
    --bg-white:     #ffffff;
    --text:         #212529;
    --text-muted:   #6c757d;
    --shadow:       0 2px 8px rgba(0, 0, 0, 0.10);
    --shadow-lg:    0 4px 20px rgba(0, 0, 0, 0.15);
    --rail-width:   230px;
    --header-height: 52px;
    --radius:       6px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure the HTML `hidden` attribute always wins over any CSS display rule. */
[hidden] { display: none !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: var(--header-height);
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-ghost {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
}

.btn-block {
    width: 100%;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.18);
}

.error-msg {
    font-size: 0.875rem;
    color: var(--error);
    background: var(--error-bg);
    border: 1px solid rgba(220, 53, 69, 0.25);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

/* ── Login screen ──────────────────────────────────────────────────────────── */
#login-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.25rem 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-card h2 {
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ── Editor screen ─────────────────────────────────────────────────────────── */
#editor-screen {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Left catalog rail */
#catalog-rail {
    width: var(--rail-width);
    flex-shrink: 0;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.rail-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.catalog-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
}

.catalog-list li {
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.9375rem;
    border-left: 3px solid transparent;
    transition: background 0.1s, border-color 0.1s;
}

.catalog-list li:hover {
    background: var(--bg-light);
}

.catalog-list li.active {
    background: #e8f0fe;
    border-left-color: var(--primary);
    font-weight: 500;
    color: var(--primary-dark);
}

/* Right tab panel */
#tab-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-white);
}

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    background: var(--bg-white);
    flex-shrink: 0;
}

.tab-btn {
    position: relative;
    padding: 0.75rem 1.125rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    padding: 1rem 0;
}

/* Alert badge on the Alerts tab button */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--error);
    color: #fff;
    line-height: 1;
}

/* ── Catalog rail items (M11) ──────────────────────────────────────────────── */
.cat-name {
    display: block;
    font-size: 0.9375rem;
}

.cat-code {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.catalog-list li.active .cat-code {
    color: var(--primary-dark);
    opacity: 0.75;
}

.rail-empty {
    padding: 1rem;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
    cursor: default !important;
}

/* ── Data tables (M11) ─────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: #f5f8ff;
}

/* thumbnail cell */
.td-thumb {
    width: 72px;
    padding: 0.3rem 0.5rem !important;
    text-align: center;
}

.thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
    display: block;
}

.no-thumb {
    display: block;
    width: 64px;
    height: 48px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 3px;
    text-align: center;
    line-height: 48px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* sku cell */
.td-sku code {
    font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-size: 0.8125rem;
    background: var(--bg-light);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* numeric count cell */
.td-num {
    text-align: center;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

/* ── Alert panel (M11) ─────────────────────────────────────────────────────── */
.alert-group {
    margin-bottom: 1.75rem;
}

.alert-group-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    display: inline-block;
}

.alert-group-error {
    color: #b91c1c;
    background: #fee2e2;
}

.alert-group-warning {
    color: #92400e;
    background: #fef3c7;
}

.alert-table td {
    padding: 0.45rem 0.75rem;
}

.td-scope {
    width: 190px;
    white-space: nowrap;
}

.scope-tag {
    font-size: 0.75rem;
    font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 6px;
    color: var(--text-muted);
}

.td-msg {
    font-size: 0.875rem;
    color: var(--text);
}

.td-action {
    width: 60px;
    text-align: right;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-outline:not(:disabled):hover {
    background: var(--bg-light);
    color: var(--text);
}

.alerts-ok {
    color: var(--success);
    font-style: normal;
    font-weight: 500;
}

/* ── Catalog rail (M12 updates) ────────────────────────────────────────────── */
.catalog-list li {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cat-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.cat-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}

.catalog-list li:hover .cat-actions,
.catalog-list li.active .cat-actions {
    display: flex;
}

/* ── Button variants (M12) ─────────────────────────────────────────────────── */
.btn-secondary {
    background: var(--bg-light);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e6ea;
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn-danger-outline {
    background: transparent;
    color: var(--error);
    border-color: rgba(220, 53, 69, 0.4);
}

.btn-danger-outline:hover:not(:disabled) {
    background: #fff5f5;
    border-color: var(--error);
}

.btn-outline-light {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.45);
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
}

.btn-outline-light:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.7);
}

/* Small icon-style rail buttons */
.btn-icon {
    background: none;
    border: 1px solid transparent;
    padding: 1px 5px;
    font-size: 0.8rem;
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1.4;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-light);
    border-color: var(--border);
    color: var(--text);
}

.btn-icon-danger:hover {
    background: #fff5f5;
    border-color: rgba(220, 53, 69, 0.4);
    color: var(--error);
}

/* ── Tab actions bar (M12) ─────────────────────────────────────────────────── */
.tab-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.td-actions {
    white-space: nowrap;
    text-align: right;
    width: 130px;
}

/* ── Drawer (M12) ──────────────────────────────────────────────────────────── */
#drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 200;
}

#entity-drawer {
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 201;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.drawer-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.btn-icon-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 0.2rem;
}

.btn-icon-close:hover { color: var(--text); }

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.drawer-footer-area {
    flex-shrink: 0;
}

.drawer-error-msg {
    margin: 0.5rem 1.25rem 0;
}

.drawer-footer {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    gap: 0.5rem;
}

.drawer-footer-right {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* ── Drawer form styles (M12) ──────────────────────────────────────────────── */
.required {
    color: var(--error);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    display: block;
}

.form-control-file {
    display: block;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    width: 100%;
}

.file-section {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
    background: var(--bg-light);
    margin-bottom: 1rem;
}

.file-section-label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
}

.image-error {
    font-size: 0.8125rem;
    color: var(--error);
    margin-top: 0.4rem;
}

.image-preview {
    display: block;
    max-width: 192px;
    height: auto;
    margin-top: 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ── Delete confirm view in drawer (M12) ───────────────────────────────────── */
.delete-confirm-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.25rem 0;
}

.delete-confirm-body p {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.delete-confirm-body strong {
    font-weight: 600;
}

.delete-confirm-warning {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ── Fabric assignment checklist in product drawer (M13) ────────────────────── */
.form-section-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 0.875rem;
    margin-bottom: 0.75rem;
    margin-top: 0.25rem;
}

.fabric-checklist {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.375rem 0.5rem;
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.fabric-check-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.375rem;
    border-radius: 3px;
    user-select: none;
}

.fabric-check-item:hover {
    background: var(--bg-light);
}

.fabric-check-item input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
}

.fab-label {
    flex: 1;
}

.fab-sku-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
}

/* ── Disabled product rows + Off badge ─────────────────────────────────────── */
.data-table tr.row-disabled td {
    opacity: 0.5;
}

.data-table tr.row-disabled .thumb {
    filter: grayscale(0.6);
}

.badge-off {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #fff;
    background: var(--text-muted);
    padding: 1px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Drawer: enabled checkbox */
.form-check .check-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.form-check input[type="checkbox"] {
    cursor: pointer;
    flex-shrink: 0;
}
