/* App layout and components; the shared glass primitives (tokens, .glass, .button, .input) are in glass.css. */

h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
}

h1 {
    font-size: 26px;
}

h2 {
    margin-bottom: 14px;
    font-size: 18px;
}

h3 {
    margin-bottom: 6px;
    font-size: 15px;
}

p {
    margin: 0 0 8px;
}

.muted {
    color: var(--text-muted);
}

/* --- shell --- */

.top-bar {
    position: sticky;
    top: 12px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    max-width: 1180px;
    margin: 12px auto 0;
    padding: 10px 16px;
}

.brand {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav,
.top-bar-end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.top-bar-end {
    margin-left: auto;
}

.nav-button {
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
}

.nav-button:hover {
    color: var(--text);
    background: var(--hover);
}

.nav-button-active {
    border-color: var(--glass-border);
    background: var(--glass-bg-strong);
    color: var(--text);
}

.user-name {
    padding: 0 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 16px 64px;
}

.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

/* --- layout helpers --- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.columns {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 820px) {
    .columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

.list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.actions-stacked {
    flex-direction: column;
    align-items: stretch;
}

.panel {
    padding: 22px;
}

.card {
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.card .actions {
    margin-top: auto;
    padding-top: 14px;
}

.card-title {
    margin: 0;
}

/* --- catalog --- */

.product-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    margin-bottom: 12px;
    border-radius: var(--radius-small);
    object-fit: cover;
    background: var(--hover);
}

.product-description {
    display: -webkit-box;
    margin-top: 4px;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-height: 3em;
}

.price {
    font-size: 17px;
    font-weight: 600;
}

/* --- forms --- */

.field {
    flex: 1;
    margin-bottom: 14px;
}

textarea.input {
    min-height: 80px;
    resize: vertical;
}

.field-row {
    display: flex;
    gap: 12px;
}

.form-error {
    color: var(--danger);
    font-size: 14px;
}

/* a field that failed validation: red outline and the reason under it, like Stripe's card fields */
.input.input-invalid,
.input.input-invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 1px var(--danger);
}

.field-error {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 13px;
}

/* --- checkout --- */

.cart-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
}

@media (max-width: 560px) {
    .cart-line {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

.stepper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stepper .button {
    width: 32px;
    padding: 4px 0;
}

.stepper-input {
    width: 56px;
    padding: 6px 4px;
    text-align: center;
}

.stepper-value {
    min-width: 24px;
    text-align: center;
}

.cart-line-subtotal {
    min-width: 90px;
    text-align: right;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    padding-top: 14px;
    font-size: 17px;
    font-weight: 600;
}

.payment-panel {
    max-width: 560px;
}

.stripe-container {
    min-height: 220px;
    margin: 16px 0;
}

/* --- orders --- */

.order {
    padding: 4px;
}

.order-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.order-header:hover {
    background: var(--hover);
}

.order-chevron {
    width: 12px;
    color: var(--text-muted);
}

.order-id {
    font-weight: 600;
}

.order-total {
    margin-left: auto;
    font-weight: 600;
}

.order-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    padding: 8px 14px 4px 42px;
}

.order .actions {
    padding: 0 14px 12px 42px;
}

.plain-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.plain-list li {
    padding: 2px 0;
}

/* --- shipments --- */

.tabs {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 18px;
    padding: 4px;
    border-radius: 12px;
}

.tab {
    padding: 7px 18px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
}

.tab-active {
    background: var(--glass-bg-strong);
    color: var(--text);
}

/* --- small components --- */

.badge {
    flex-shrink: 0;
    padding: 3px 10px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

.badge-neutral {
    color: var(--text-muted);
}

.badge-info {
    color: var(--info);
}

.badge-success {
    color: var(--success);
}

.badge-warning {
    color: var(--warning);
}

.badge-danger {
    color: var(--danger);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 24px;
}

.pagination-label {
    color: var(--text-muted);
    font-size: 14px;
}

.empty-state {
    padding: 40px 0;
    color: var(--text-muted);
    text-align: center;
}

.spinner {
    width: 32px;
    height: 32px;
    margin: 40px auto;
    border: 3px solid var(--divider);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--backdrop);
}

.dialog {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 24px;
    background: var(--surface);
}

.dialog-title {
    margin-bottom: 18px;
}

.toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(380px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    font-size: 14px;
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-close {
    margin-left: auto;
    padding: 0 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.fatal {
    max-width: 480px;
    margin: 80px auto;
}
