/* CrosswordApp page composition helpers. Bootstrap owns controls, typography,
   cards, forms, alerts, tables, and the overall visual theme. */

:root {
    --tender-border: var(--bs-border-color, #dee2e6);
    --tender-muted: var(--bs-secondary-color, #6c757d);
    --tender-soft: var(--bs-tertiary-bg, #f8f9fa);
}

.page-heading,
.section-heading {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-heading h1,
.section-heading h2,
.section-heading h3 {
    margin-bottom: .25rem;
}

.page-heading p,
.section-heading p,
.muted {
    color: var(--tender-muted);
}

.page-heading p,
.section-heading p {
    margin-bottom: 0;
}

.page-actions,
.form-actions,
.cluster {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.page-actions,
.form-actions {
    justify-content: flex-end;
}

.form-actions {
    margin-top: 1rem;
}

.eyebrow {
    color: var(--bs-primary);
    display: block;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .075em;
    margin-bottom: .25rem;
    text-transform: uppercase;
}

.content-grid {
    align-items: start;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, .4fr);
}

.stack {
    display: grid;
    gap: 1rem;
}

.divider {
    background: var(--tender-border);
    height: 1px;
    margin: 1.25rem 0;
}

.stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--tender-border);
    border-radius: var(--bs-border-radius);
    padding: 1rem;
}

.stat-label,
.stat-note {
    color: var(--tender-muted);
    display: block;
    font-size: .8rem;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
    margin: .25rem 0;
}

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-group {
    min-width: 0;
}

.form-group-wide {
    grid-column: 1 / -1;
}

.form-help {
    color: var(--tender-muted);
    display: block;
    font-size: .8rem;
    margin-top: .25rem;
}

.btn-block {
    width: 100%;
}

.btn-quiet {
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-border-color: var(--bs-secondary-border-subtle);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--bs-secondary);
    --bs-btn-hover-border-color: var(--bs-secondary);
}

.btn-danger-quiet {
    --bs-btn-color: var(--bs-danger);
    --bs-btn-border-color: var(--bs-danger);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--bs-danger);
    --bs-btn-hover-border-color: var(--bs-danger);
}

.icon-button {
    align-items: center;
    background: transparent;
    border: 1px solid var(--tender-border);
    border-radius: var(--bs-border-radius);
    color: var(--bs-body-color);
    cursor: pointer;
    display: inline-flex;
    height: 2.25rem;
    justify-content: center;
    width: 2.25rem;
}

.alert-error {
    --bs-alert-color: var(--bs-danger-text-emphasis);
    --bs-alert-bg: var(--bs-danger-bg-subtle);
    --bs-alert-border-color: var(--bs-danger-border-subtle);
    --bs-alert-link-color: var(--bs-danger-text-emphasis);
}

.alert-mark {
    font-weight: 700;
    margin-right: .35rem;
}

.alert p {
    display: inline;
    margin: 0;
}

.state-card {
    align-items: center;
    background: var(--bs-body-bg);
    border: 1px solid var(--tender-border);
    border-radius: var(--bs-border-radius-lg);
    display: flex;
    gap: 1rem;
    justify-content: center;
    min-height: 18rem;
    padding: 2rem;
    text-align: center;
}

.state-card p {
    color: var(--tender-muted);
    margin: 0 auto 1rem;
    max-width: 32rem;
}

.state-card-error {
    background: var(--bs-danger-bg-subtle);
    border-color: var(--bs-danger-border-subtle);
}

.state-icon {
    align-items: center;
    background: var(--bs-primary-bg-subtle);
    border-radius: var(--bs-border-radius);
    color: var(--bs-primary-text-emphasis);
    display: inline-flex;
    flex: 0 0 2.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    height: 2.75rem;
    justify-content: center;
}

.route-progress {
    align-items: center;
    color: var(--tender-muted);
    display: flex;
    gap: .75rem;
    justify-content: center;
    min-height: 70vh;
}

.spinner {
    animation: tender-spin .75s linear infinite;
    border: .2rem solid rgba(var(--bs-primary-rgb), .25);
    border-radius: 50%;
    border-top-color: var(--bs-primary);
    display: inline-block;
    height: 1.25rem;
    width: 1.25rem;
}

@keyframes tender-spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    animation: tender-pulse 1.5s ease-in-out infinite;
    background: var(--tender-soft);
    border-radius: var(--bs-border-radius-sm);
    min-height: 1rem;
}

@keyframes tender-pulse {
    50% { opacity: .45; }
}

.table-shell {
    border: 1px solid var(--tender-border);
    border-radius: var(--bs-border-radius);
    overflow-x: auto;
}

.data-table {
    border-color: var(--tender-border);
    margin-bottom: 0;
    vertical-align: middle;
    width: 100%;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--tender-border);
    padding: .75rem;
    text-align: left;
}

.data-table th {
    background: var(--tender-soft);
    color: var(--tender-muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: rgba(var(--bs-primary-rgb), .035);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.cell-title,
.cell-subtitle {
    display: block;
}

.cell-title {
    font-weight: 600;
}

.cell-subtitle {
    color: var(--tender-muted);
    font-size: .8rem;
}

.cell-actions {
    display: flex;
    gap: .4rem;
    justify-content: flex-end;
}

.table-empty {
    color: var(--tender-muted);
    padding: 2.5rem 1rem !important;
    text-align: center !important;
}

.toolbar,
.pagination-bar {
    align-items: center;
    display: flex;
    gap: .75rem;
    justify-content: space-between;
}

.toolbar {
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.search-control {
    position: relative;
    width: min(100%, 22rem);
}

.search-control .form-control {
    padding-left: 2.25rem;
}

.search-mark {
    color: var(--tender-muted);
    left: .8rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.pagination-bar {
    border-top: 1px solid var(--tender-border);
    color: var(--tender-muted);
    font-size: .875rem;
    padding: .75rem;
}

.avatar {
    align-items: center;
    background: var(--bs-primary-bg-subtle);
    border-radius: 50%;
    color: var(--bs-primary-text-emphasis);
    display: inline-flex;
    flex: 0 0 2.5rem;
    font-size: .8rem;
    font-weight: 600;
    height: 2.5rem;
    justify-content: center;
    overflow: hidden;
}

.avatar img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.avatar-sm {
    flex-basis: 2rem;
    height: 2rem;
}

.avatar-lg {
    flex-basis: 5rem;
    font-size: 1.25rem;
    height: 5rem;
}

.person,
.profile-summary,
.connection-card {
    align-items: center;
    display: flex;
    gap: .75rem;
}

.person {
    min-width: 11rem;
}

.badge-success {
    background: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
}

.badge-warning {
    background: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
}

.badge-info {
    background: var(--bs-info-bg-subtle);
    color: var(--bs-info-text-emphasis);
}

.tabs {
    border-bottom: 1px solid var(--tender-border);
    display: flex;
    gap: .25rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.tab-button {
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--tender-muted);
    cursor: pointer;
    font-weight: 500;
    padding: .65rem .85rem;
    white-space: nowrap;
}

.tab-button.active {
    border-bottom-color: var(--bs-primary);
    color: var(--bs-primary);
}

.count-pill {
    background: var(--bs-secondary-bg);
    border-radius: 50rem;
    font-size: .75rem;
    margin-left: .25rem;
    padding: .1rem .4rem;
}

.auth-page {
    display: grid;
    min-height: calc(100vh - 8rem);
    padding: 2rem 0;
    place-items: center;
}

.auth-shell {
    background: var(--bs-body-bg);
    border: 1px solid var(--tender-border);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--bs-box-shadow);
    display: grid;
    grid-template-columns: minmax(16rem, .8fr) minmax(20rem, 1.2fr);
    overflow: hidden;
    width: min(100%, 64rem);
}

.auth-aside {
    background: var(--bs-primary);
    color: rgba(255, 255, 255, .85);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 34rem;
    padding: 2rem;
}

.auth-aside h2 {
    color: #fff;
}

.auth-aside p {
    color: rgba(255, 255, 255, .75);
}

.auth-points,
.password-rules {
    padding-left: 1.25rem;
}

.auth-card {
    align-self: center;
    padding: 2rem clamp(1.25rem, 5vw, 3rem);
}

.auth-links {
    align-items: center;
    display: flex;
    font-size: .875rem;
    gap: 1rem;
    justify-content: space-between;
    margin: .75rem 0 1rem;
}

.auth-footer {
    color: var(--tender-muted);
    font-size: .875rem;
    margin: 1.25rem 0 0;
    text-align: center;
}

.password-rules {
    color: var(--tender-muted);
    font-size: .8rem;
    margin-top: .5rem;
}

.hero {
    align-items: center;
    display: grid;
    gap: clamp(2rem, 7vw, 5rem);
    grid-template-columns: minmax(0, 1.1fr) minmax(18rem, .9fr);
    min-height: 31rem;
    padding: clamp(1rem, 5vw, 4rem) 0;
}

.hero-copy h1 {
    font-size: clamp(2.25rem, 5vw, 4rem);
    margin: .5rem 0 1rem;
    max-width: 46rem;
}

.hero-copy h1 span {
    color: var(--bs-primary);
}

.hero-copy > p {
    color: var(--tender-muted);
    font-size: 1.1rem;
    max-width: 39rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.5rem;
}

.hero-panel,
.opportunity-card,
.feature-card,
.connection-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--tender-border);
    border-radius: var(--bs-border-radius-lg);
}

.hero-panel {
    box-shadow: var(--bs-box-shadow);
    padding: 1rem;
}

.opportunity-card,
.feature-card,
.connection-card {
    padding: 1rem;
}

.opportunity-card + .opportunity-card {
    margin-top: .75rem;
}

.opportunity-top {
    display: flex;
    gap: .75rem;
    justify-content: space-between;
}

.progress-track {
    background: var(--bs-secondary-bg);
    border-radius: 50rem;
    height: .4rem;
    margin-top: .75rem;
    overflow: hidden;
}

.progress-fill {
    background: var(--bs-primary);
    height: 100%;
}

.feature-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 3rem;
}

.feature-card p {
    color: var(--tender-muted);
    margin-bottom: 0;
}

.profile-summary h2,
.profile-summary p {
    margin-bottom: 0;
}

.profile-summary p,
.connection-body span {
    color: var(--tender-muted);
}

.profile-image-upload input[type="file"] {
    width: 100%;
}

.upload-progress {
    align-items: center;
    color: var(--tender-muted);
    display: grid;
    font-size: .8rem;
    gap: .5rem;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: .75rem;
}

.upload-progress progress {
    width: 100%;
}

.image-upload-alert {
    margin: .75rem 0 0;
}

.role-list,
.connection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.role-list {
    margin-top: .5rem;
}

.list-grid {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.connection-body {
    flex: 1;
    min-width: 0;
}

.connection-body strong,
.connection-body span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.connection-body span {
    font-size: .8rem;
}

.modal-backdrop {
    align-items: center;
    background: rgba(0, 0, 0, .5);
    display: flex;
    justify-content: center;
    opacity: 1;
    padding: 1rem;
}

.dialog {
    background: var(--bs-body-bg);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--bs-box-shadow-lg);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    width: min(100%, 31rem);
}

.dialog-wide {
    width: min(100%, 46rem);
}

.card-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.dialog-header,
.dialog-footer {
    align-items: center;
    display: flex;
    gap: .75rem;
    justify-content: space-between;
    padding: 1rem;
}

.dialog-header {
    border-bottom: 1px solid var(--tender-border);
}

.dialog-header h2 {
    margin: 0;
}

.dialog-body {
    padding: 1rem;
}

.dialog-footer {
    background: var(--tender-soft);
    border-top: 1px solid var(--tender-border);
    justify-content: flex-end;
}

@media (max-width: 1080px) {
    .content-grid,
    .hero {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-panel {
        width: min(100%, 42rem);
    }
}

@media (max-width: 760px) {
    .page-heading {
        display: block;
    }

    .page-actions {
        justify-content: flex-start;
        margin-top: 1rem;
    }

    .form-grid,
    .list-grid,
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .form-group-wide {
        grid-column: auto;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        display: none;
    }
}

@media (max-width: 520px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .connection-card {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .connection-actions {
        width: 100%;
    }

    .connection-actions .btn {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
