/*
 * Fitly Shared Components (fitly-components.css)
 * ════════════════════════════════════════════════
 * Styles for shared Blazor components in Fitly.Shared.Views.
 * Loaded AFTER fitly-tokens.css. Uses Bootstrap classes where
 * possible; custom classes use the component name as prefix.
 *
 * Components whose styles were previously in:
 *   - shared-design-system.css (modal, loading, search, error, card)
 *   - design-system.css (buttons, cards, forms, modals, badges, avatars, lists)
 *   - Various .razor.css files in Shared.Views
 */

/* ══════════════════════════════════════════════════════════
   Shared Modal (.shared-modal)
   ══════════════════════════════════════════════════════════ */
.shared-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--fitly-z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.shared-modal.visible {
    display: flex !important;
}

.shared-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--fitly-z-modal-backdrop);
}

.shared-modal .modal-content {
    position: relative;
    background: var(--bs-card-bg, #fff);
    border-radius: var(--bs-border-radius-xl, 12px);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--bs-border-color, #dee2e6);
    z-index: var(--fitly-z-modal);
    animation: fitlyModalFadeIn 0.2s ease-out;
}

.shared-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.shared-modal .modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--bs-body-color, #212529);
}

.shared-modal .modal-body {
    padding: 20px;
}

.shared-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-secondary-bg, #f8f9fa);
    border-radius: 0 0 var(--bs-border-radius-xl, 12px) var(--bs-border-radius-xl, 12px);
}

@keyframes fitlyModalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Modal Backdrop (design-system) ────────────────────── */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--fitly-modal-backdrop);
    z-index: var(--fitly-z-modal-backdrop);
    backdrop-filter: blur(8px);
    animation: fitlyFadeIn 0.3s ease-out;
}

.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--fitly-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--fitly-spacing-xl);
}

/* Modal footer buttons (design-system) */
.modal-footer-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
}

.modal-footer-buttons .btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes fitlyFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fitlyModalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════════════════════════
   Loading Modal
   ══════════════════════════════════════════════════════════ */
.loading-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--fitly-z-loading);
}

.loading-modal-content {
    background: var(--bs-card-bg);
    border-radius: var(--border-radius);
    padding: var(--fitly-spacing-3xl);
    text-align: center;
    box-shadow: var(--fitly-shadow-xl);
    max-width: 320px;
    width: 90%;
}

.loading-modal-spinner .spinner {
    border: 3px solid var(--fitly-border-light);
    border-top: 3px solid var(--bs-primary);
    border-radius: 50%;
    animation: fitlySpin 0.8s linear infinite;
    margin: 0 auto;
}

.spinner-sm { width: 24px; height: 24px; }
.spinner-md { width: 40px; height: 40px; }
.spinner-lg { width: 56px; height: 56px; }

@keyframes fitlySpin {
    to { transform: rotate(360deg); }
}

.loading-modal-message h3 {
    margin: var(--fitly-spacing-lg) 0 0;
    font-size: var(--fitly-font-size-base);
    color: var(--bs-body-color);
    font-weight: var(--fitly-font-weight-semibold);
}

.loading-modal-submessage p {
    margin: var(--fitly-spacing-sm) 0 0;
    font-size: var(--fitly-font-size-sm);
    color: var(--bs-secondary);
}

/* ══════════════════════════════════════════════════════════
   Search Container
   ══════════════════════════════════════════════════════════ */
.search-container {
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper input {
    width: 100%;
    padding: var(--fitly-spacing-sm) var(--fitly-spacing-lg) var(--fitly-spacing-sm) 40px;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-pill);
    background: var(--bs-secondary-bg);
    font-size: var(--fitly-font-size-sm);
    color: var(--bs-body-color);
    outline: none;
    transition: border-color var(--fitly-transition-fast), box-shadow var(--fitly-transition-fast);
}

.search-input-wrapper input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb, 3, 169, 245), 0.15);
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--fitly-text-muted);
    pointer-events: none;
}

/* ── Filter dropdowns ──────────────────────────────────── */
.filter-dropdowns {
    display: flex;
    gap: var(--fitly-spacing-sm);
    flex-wrap: wrap;
    margin-top: var(--fitly-spacing-sm);
}

.filter-dropdown select {
    padding: var(--fitly-spacing-xs) var(--fitly-spacing-md);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--bs-card-bg);
    font-size: var(--fitly-font-size-sm);
    color: var(--bs-body-color);
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
   Error Container
   ══════════════════════════════════════════════════════════ */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--fitly-spacing-4xl) var(--fitly-spacing-lg);
    text-align: center;
}

/* ══════════════════════════════════════════════════════════
   Badge Components (design-system)
   ══════════════════════════════════════════════════════════ */
.badge-primary {
    background-color: var(--fitly-primary-bg);
    color: var(--bs-primary);
    border: 1px solid var(--bs-primary);
}

.badge-secondary {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-secondary);
    border: 1px solid var(--bs-secondary);
}

.badge-success {
    background-color: var(--fitly-success-light);
    color: var(--bs-success);
    border: 1px solid var(--bs-success);
}

/* ══════════════════════════════════════════════════════════
   Avatar Components
   ══════════════════════════════════════════════════════════ */
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--fitly-border-radius-circle);
    font-weight: var(--fitly-font-weight-bold);
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--fitly-font-size-xs); }
.avatar-md { width: 48px; height: 48px; font-size: var(--fitly-font-size-sm); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--fitly-font-size-base); }

.avatar-primary {
    background: linear-gradient(135deg, var(--bs-primary), var(--fitly-primary-hover));
    color: var(--fitly-text-inverse);
}

.avatar-secondary {
    background: linear-gradient(135deg, var(--bs-secondary), var(--fitly-secondary-hover));
    color: var(--fitly-text-inverse);
}

/* ══════════════════════════════════════════════════════════
   Mobile Action List
   ══════════════════════════════════════════════════════════ */
.mobile-actions-section {
    margin-bottom: var(--fitly-spacing-2xl);
}

.mobile-section-title {
    font-size: var(--fitly-font-size-lg);
    font-weight: var(--fitly-font-weight-bold);
    color: var(--bs-body-color);
    margin-bottom: var(--fitly-spacing-lg);
    padding-left: var(--fitly-spacing-sm);
}

.mobile-actions-list {
    display: flex;
    flex-direction: column;
    gap: var(--fitly-spacing-sm);
}

.mobile-action-item {
    display: flex;
    align-items: center;
    padding: var(--fitly-spacing-lg);
    background-color: var(--bs-card-bg);
    border: 1px solid var(--fitly-border-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--fitly-transition-normal);
    text-align: left;
    width: 100%;
    min-height: 72px;
    box-shadow: var(--fitly-shadow-xs);
}

.mobile-action-item:hover {
    background-color: var(--bs-secondary-bg);
    border-color: var(--bs-primary);
    transform: translateY(-1px);
    box-shadow: var(--fitly-shadow-sm);
}

.mobile-action-item:active {
    transform: translateY(0);
    box-shadow: var(--fitly-shadow-xs);
}

.mobile-action-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--bs-border-radius-sm);
    background-color: var(--fitly-primary-bg);
    color: var(--fitly-text-inverse);
    margin-right: var(--fitly-spacing-lg);
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   App Status Bar Icon Buttons
   ══════════════════════════════════════════════════════════ */
.app-bar-icon-btn,
.app-status-bar-content .right-section {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--fitly-spacing-sm);
    border-radius: var(--fitly-border-radius-circle);
    color: var(--bs-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--fitly-transition-normal);
    min-width: 44px;
    min-height: 44px;
    position: relative;
}

.app-bar-icon-btn:hover,
.app-status-bar-content .right-section:hover {
    color: var(--fitly-primary-hover);
}

.app-bar-icon-btn:active,
.app-status-bar-content .right-section:active {
    transform: scale(0.95);
    transition: var(--fitly-transition-fast);
}

/* ----------------------------------------------------------------
   Smart Coach modal body
   ---------------------------------------------------------------- */
.smart-coach-modal-body {
    overflow-y: auto;
    padding: 1.25rem;
}

/* Force every direct child of the Smart Coach modal body to render at its
   natural height without inheriting host-app .card { overflow: hidden } or
   the SharedModal fade-in animation that was clipping content on the web. */
.smart-coach-modal-body > * {
    animation: none !important;
}

.smart-coach-modal-body .card {
    overflow: visible !important;
    transition: none !important;
    transform: none !important;
}

.smart-coach-modal-body .card:hover {
    transform: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

.smart-coach-modal-body .table-responsive {
    overflow-x: auto;
    overflow-y: visible;
}

.smart-coach-modal-body .table {
    margin-bottom: 0;
}

.smart-coach-modal-body .table th,
.smart-coach-modal-body .table td {
    white-space: normal;
    word-break: break-word;
    vertical-align: top;
}
