/* Breakpoints match Services/ViewportService.cs / wwwroot/js/interop.js:
   <700px phone, 700-1100px tablet, >=1100px desktop. */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
}

body {
    font-family: "Segoe UI", system-ui, sans-serif;
    color: #1a1a1a;
    background: #f7f7f8;
}

/* ---- Login page ---- */

.login-shell {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f3f4f6;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 22rem;
    width: 100%;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-error {
    color: #b91c1c;
}

/* ---- App shell / header ---- */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    border-top: 4px solid #3b82f6; /* overridden by accent-dev/accent-prd */
}

.app-shell.accent-dev {
    border-top-color: #1e90ff; /* DodgerBlue, matches the WPF DEV accent */
}

.app-shell.accent-prd {
    border-top-color: #dc143c; /* Crimson, matches the WPF PRD accent */
}

.app-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.app-title {
    font-weight: 600;
}

.app-env-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
}

.spacer {
    flex: 1 1 auto;
}

.save-button {
    background: #e5e7eb;
    color: #9ca3af;
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: default;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.save-button:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: default;
}

/* Enabled only when there are unsaved changes -- the button itself is the
   indicator, so it needs to visually pop against the otherwise-muted disabled
   look above, not just toggle a cursor style. */
.save-button-dirty {
    background: #d97706;
    color: white;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}

.save-button-dirty:hover {
    background: #b45309;
}

.logout-button {
    background: transparent;
    border: 1px solid #d1d5db;
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
}

.app-main {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 1rem 1rem;
    gap: 0.5rem;
}

.page-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0;
}

.loading-message {
    padding: 2rem;
    text-align: center;
    color: #4b5563;
}

/* ---- Status bar ---- */

.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.85rem;
    color: #374151;
    padding: 0.35rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.status-transient {
    color: #2563eb;
}

/* ---- Filters (desktop/tablet) ---- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0;
}

.filter-bar input[type="search"] {
    min-width: 10rem;
}

.price-filter-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.price-filter-group input {
    width: 5rem;
}

/* ---- Grid (desktop/tablet) ---- */

.collection-split {
    flex: 1 1 auto;
    display: flex;
    gap: 1rem;
    min-height: 0;
}

.grid-scroll {
    flex: 1 1 auto;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    min-height: 0;
}

table.card-grid {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
}

table.card-grid thead th {
    position: sticky;
    top: 0;
    background: #f3f4f6;
    text-align: left;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 1px solid #d1d5db;
    z-index: 1;
}

table.card-grid td {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

table.card-grid tbody tr:hover {
    background: #f9fafb;
}

table.card-grid tbody tr.selected {
    background: #dbeafe;
}

table.card-grid td.text-cell textarea {
    width: 100%;
    min-width: 12rem;
    resize: vertical;
}

table.card-grid td.mono {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.75rem;
}

table.card-grid input[type="number"] {
    width: 4rem;
}

.lookup-side {
    width: 22rem;
    flex: 0 0 auto;
    overflow-y: auto;
}

.lookup-side.lookup-slideover {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(24rem, 90vw);
    background: white;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    z-index: 20;
}

/* ---- Scryfall lookup panel ---- */

.scryfall-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.scryfall-search {
    display: flex;
    gap: 0.5rem;
}

.scryfall-image {
    max-width: 100%;
    border-radius: 6px;
    align-self: center;
}

.printing-info {
    font-size: 0.85rem;
    color: #4b5563;
}

.cycling-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scryfall-status {
    color: #b45309;
    font-size: 0.85rem;
}

.scryfall-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.row-context {
    font-size: 0.8rem;
    color: #6b7280;
}

/* ---- Phone: filter drawer ---- */

.filter-drawer-trigger {
    align-self: flex-start;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    position: relative;
}

.filter-count-badge {
    background: #2563eb;
    color: white;
    border-radius: 999px;
    font-size: 0.7rem;
    padding: 0.05rem 0.4rem;
    margin-left: 0.4rem;
}

.filter-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 30;
}

.filter-drawer-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    overflow-y: auto;
    background: white;
    border-radius: 12px 12px 0 0;
    padding: 1rem;
    z-index: 31;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.filter-drawer-close {
    background: none;
    border: none;
    font-size: 1.1rem;
}

.filter-drawer-sheet label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.filter-drawer-actions {
    display: flex;
    gap: 0.5rem;
}

/* ---- Phone: card list ---- */

.card-list-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
}

.card-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.25rem;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.card-list-row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.card-list-row-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-list-row-chips {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.15rem;
}

.chip {
    font-size: 0.7rem;
    background: #f3f4f6;
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    color: #4b5563;
}

.chip-price {
    background: #ecfdf5;
    color: #047857;
}

.card-list-row-stepper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.card-list-row-stepper button {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: white;
    font-size: 1rem;
}

.stepper-value {
    min-width: 1.5rem;
    text-align: center;
}

/* ---- Phone: card detail page ---- */

.back-link {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.card-detail {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    overflow-y: auto;
}

.card-detail-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.6rem;
    font-size: 0.9rem;
}

.card-detail-fields dt {
    color: #6b7280;
}

.card-detail-fields dd {
    margin: 0;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.detail-field textarea {
    min-height: 5rem;
}
