/**
 * Wahive Design System — Shared Components
 * Empty states, loading, page chrome, error pages.
 * Requires wahive-tokens.css
 */

/* ── Page Header ── */
.wahive-page-header-v2 {
    padding: var(--wahive-page-padding-y) var(--wahive-page-padding-x) var(--wahive-space-4);
}

.wahive-page-header-v2__breadcrumb {
    margin-bottom: var(--wahive-space-3);
}

.wahive-page-header-v2__breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wahive-space-1);
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: var(--wahive-font-size-sm);
}

.wahive-page-header-v2__breadcrumb li + li::before {
    content: '/';
    margin-right: var(--wahive-space-2);
    color: var(--wahive-text-muted);
}

.wahive-page-header-v2__breadcrumb a {
    color: var(--wahive-text-muted);
    text-decoration: none;
    transition: color var(--wahive-transition);
}

.wahive-page-header-v2__breadcrumb a:hover {
    color: var(--wahive-brand);
}

.wahive-breadcrumb-sep {
    margin: 0 0.5rem;
    font-size: 0.65rem;
    color: var(--wahive-text-muted, #737373);
    opacity: 0.7;
}

.wahive-page-header-v2__breadcrumb li[aria-current] {
    color: var(--wahive-text-primary);
    font-weight: var(--wahive-font-weight-medium);
}

.wahive-page-header-v2__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--wahive-space-4);
}

.wahive-page-header-v2__title {
    font-size: var(--wahive-font-size-2xl);
    font-weight: var(--wahive-font-weight-semibold);
    color: var(--wahive-text-primary);
    margin: 0;
    line-height: 1.25;
}

@media (min-width: 768px) {
    .wahive-page-header-v2__title {
        font-size: var(--wahive-font-size-3xl);
    }
}

.wahive-page-header-v2__description {
    font-size: var(--wahive-font-size-base);
    color: var(--wahive-text-muted);
    margin: var(--wahive-space-3) 0 0;
    max-width: 640px;
    line-height: var(--wahive-line-height);
}

.wahive-page-header-v2__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.wahive-page-header-v2__actions > * + * {
    margin-left: var(--wahive-space-2);
}

.wahive-page-header-v2__back {
    display: inline-flex;
    align-items: center;
    gap: var(--wahive-space-2);
    font-size: var(--wahive-font-size-sm);
    color: var(--wahive-text-muted);
    text-decoration: none;
    margin-bottom: var(--wahive-space-3);
    transition: color var(--wahive-transition);
}

.wahive-page-header-v2__back:hover {
    color: var(--wahive-brand);
}

/* ── Empty State ── */
.wahive-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--wahive-space-12) var(--wahive-space-6);
    min-height: 240px;
}

.wahive-empty__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: var(--wahive-radius-md);
    background: var(--wahive-brand-subtle);
    color: var(--wahive-brand);
    font-size: 1.5rem;
    margin-bottom: var(--wahive-space-5);
}

.wahive-empty__title {
    font-size: var(--wahive-font-size-lg);
    font-weight: var(--wahive-font-weight-semibold);
    color: var(--wahive-text-primary);
    margin: 0 0 var(--wahive-space-2);
}

.wahive-empty__message {
    font-size: var(--wahive-font-size-sm);
    color: var(--wahive-text-muted);
    margin: 0 0 var(--wahive-space-6);
    max-width: 400px;
    line-height: var(--wahive-line-height);
}

.wahive-empty__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wahive-space-3);
    justify-content: center;
}

/* ── Loading State ── */
.wahive-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--wahive-space-10) var(--wahive-space-6);
    min-height: 200px;
    color: var(--wahive-text-muted);
    font-size: var(--wahive-font-size-sm);
}

.wahive-loading__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--wahive-border);
    border-top-color: var(--wahive-brand);
    border-radius: 50%;
    animation: wahive-spin 0.7s linear infinite;
    margin-bottom: var(--wahive-space-4);
}

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

.wahive-skeleton {
    background: linear-gradient(90deg, var(--wahive-border) 25%, var(--wahive-bg-subtle) 50%, var(--wahive-border) 75%);
    background-size: 200% 100%;
    animation: wahive-shimmer 1.5s infinite;
    border-radius: var(--wahive-radius);
}

@keyframes wahive-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.wahive-skeleton--text {
    height: 14px;
    margin-bottom: var(--wahive-space-2);
}

.wahive-skeleton--title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--wahive-space-4);
}

.wahive-skeleton--card {
    height: 120px;
    margin-bottom: var(--wahive-space-4);
}

/* ── Buttons (component-level) ── */
.wahive-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--wahive-space-2);
    min-height: var(--wahive-touch-min);
    padding: 0 var(--wahive-space-5);
    font-family: var(--wahive-font);
    font-size: var(--wahive-font-size-sm);
    font-weight: var(--wahive-font-weight-medium);
    line-height: 1;
    border-radius: var(--wahive-radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--wahive-transition), color var(--wahive-transition), border-color var(--wahive-transition), box-shadow var(--wahive-transition);
}

.wahive-btn:focus-visible {
    outline: none;
    box-shadow: var(--wahive-focus-ring);
}

.wahive-btn--primary {
    background: var(--wahive-brand);
    color: var(--wahive-text-inverse);
}

.wahive-btn--primary:hover {
    background: var(--wahive-brand-hover);
    color: var(--wahive-text-inverse);
}

.wahive-btn--secondary {
    background: var(--wahive-bg-surface);
    color: var(--wahive-text-primary);
    border-color: var(--wahive-border);
}

.wahive-btn--secondary:hover {
    background: var(--wahive-bg-subtle);
    border-color: var(--wahive-border-strong);
}

.wahive-btn--ghost {
    background: transparent;
    color: var(--wahive-text-muted);
}

.wahive-btn--ghost:hover {
    background: var(--wahive-bg-subtle);
    color: var(--wahive-text-primary);
}

.wahive-btn--sm {
    min-height: 36px;
    padding: 0 var(--wahive-space-4);
    font-size: var(--wahive-font-size-xs);
}

/* ── Alert Banner (component) ── */
.wahive-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--wahive-space-3);
    padding: var(--wahive-space-4) var(--wahive-space-5);
    border-radius: var(--wahive-radius-md);
    font-size: var(--wahive-font-size-sm);
    line-height: var(--wahive-line-height);
    margin-bottom: var(--wahive-space-4);
}

.wahive-alert__icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.wahive-alert__content {
    flex: 1;
    min-width: 0;
}

.wahive-alert__content a {
    color: inherit;
    font-weight: var(--wahive-font-weight-medium);
    text-decoration: underline;
}

.wahive-alert--danger {
    background: var(--wahive-error-bg);
    color: #991b1b;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.wahive-alert--warning {
    background: var(--wahive-warning-bg);
    color: #92400e;
    border: 1px solid rgba(217, 119, 6, 0.2);
}

.wahive-alert--info {
    background: var(--wahive-info-bg);
    color: #1e40af;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.wahive-alert--success {
    background: var(--wahive-success-bg);
    color: var(--wahive-brand-hover, #e55a00);
    border: 1px solid rgba(255, 102, 0, 0.25);
}

/* ── Error Pages ── */
.wahive-error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--wahive-space-8);
    font-family: var(--wahive-font);
    background: var(--wahive-bg-page);
    color: var(--wahive-text-primary);
}

.wahive-error-page__logo {
    max-height: 48px;
    width: auto;
    margin-bottom: var(--wahive-space-10);
}

.wahive-error-page__card {
    background: var(--wahive-bg-surface);
    border: 1px solid var(--wahive-border);
    border-radius: var(--wahive-radius-xl);
    padding: var(--wahive-space-10) var(--wahive-space-8);
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: var(--wahive-shadow-md);
}

.wahive-error-page__code {
    font-size: 4rem;
    font-weight: var(--wahive-font-weight-bold);
    color: var(--wahive-brand);
    line-height: 1;
    margin: 0 0 var(--wahive-space-4);
}

.wahive-error-page__title {
    font-size: var(--wahive-font-size-xl);
    font-weight: var(--wahive-font-weight-semibold);
    margin: 0 0 var(--wahive-space-3);
}

.wahive-error-page__message {
    font-size: var(--wahive-font-size-sm);
    color: var(--wahive-text-muted);
    margin: 0 0 var(--wahive-space-8);
    line-height: var(--wahive-line-height);
}

.wahive-error-page__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wahive-space-3);
    justify-content: center;
}

/* ── Content wrapper ── */
.wahive-content {
    max-width: var(--wahive-content-max);
    margin: 0 auto;
    padding: 0 var(--wahive-space-4);
}

@media (min-width: 768px) {
    .wahive-content {
        padding: 0 var(--wahive-space-6);
    }
}

/* ── Mobile table card mode helper ── */
@media (max-width: 767px) {
    .wahive-table-responsive-cards .table-responsive {
        border: none;
    }

    body.wahive-ui .modal-dialog {
        margin: var(--wahive-space-2);
        max-width: calc(100% - var(--wahive-space-4));
    }
}
