/* frontend/styles/components.css */

/* ==========================================================================
   1. KARTY I PANELE (CARDS & PANELS)
   ========================================================================== */
.glass-panel, .card, .workout-tile, .search-card, .result-card, .cali-card, .stat-card, .auth-form-wrapper, .dashboard-grid > div, .records-toolbar, .plans-toolbar, .trainings-header {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Wariant karty z większym zaokrągleniem (używany w Dashboard i Statystykach) */
.card-xl, .stat-card, .dashboard-grid > div {
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
}

/* Hover effect dla interaktywnych kart */
.card.clickable:hover, .workout-tile:hover, .action-card:hover, .cali-card--interactive:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--highlight);
}

/* Warianty kart funkcyjnych */
.create-plan-card, .action-card {
    display: flex;
    text-decoration: none;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    align-items: center;
    gap: var(--space-md);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.create-plan-card .icon-bg, .action-card .icon-bg {
    width: 50px;
    height: 50px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.create-plan-card:hover .icon-bg, .action-card:hover .icon-bg {
    background: var(--bg-primary-alpha);
    color: var(--highlight);
}

.create-plan-card .text h3, .action-card .text h3 {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--text-main);
    margin-bottom: var(--space-xs);
}

.create-plan-card .text small, .action-card .text small {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ==========================================================================
   2. PRZYCISKI (BUTTONS)
   ========================================================================== */
.btn, button, .btn-primary, .btn-secondary, .btn-finish, .btn-discard, .btn-primary-small, .btn-outline, .btn-primary-large, .btn-secondary-large {
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-family: var(--font-main);
}

/* Primary (Główny przycisk używający motywu) */
.btn-primary, .btn-finish, .btn-search, .btn-primary-small, .btn-primary-large {
    background: linear-gradient(135deg, var(--highlight), var(--accent-color));
    color: #ffffff; /* Zawsze biały na kolorowym gradiencie */
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover, .btn-finish:hover, .btn-search:hover, .btn-primary-small:hover, .btn-primary-large:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 20px var(--shadow-primary);
}

.btn-primary-large, .btn-secondary-large {
    padding: 16px 36px;
    font-size: var(--text-lg);
    border-radius: 40px;
}

/* Secondary (Ghost/Outline) */
.btn-secondary, .btn-secondary-large, .btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover, .btn-secondary-large:hover, .btn-outline:hover {
    background: var(--bg-surface);
    border-color: var(--highlight);
    color: var(--highlight);
}

/* Danger (Usuwanie / Odrzucanie) */
.btn-danger, .btn-discard, .btn-delete {
    background: rgba(255, 77, 77, 0.1);
    color: var(--color-danger);
    border: 1px solid rgba(255, 77, 77, 0.2);
}
.btn-danger:hover, .btn-discard:hover, .btn-delete:hover {
    background: rgba(255, 77, 77, 0.2);
}

/* Przyciski ikon (Mini Button) */
.btn-icon-only, .btn-details, .btn-add-set, .btn-close {
    padding: var(--space-sm);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: var(--bg-input);
    border: 1px solid transparent;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-details:hover, .btn-add-set:hover {
    background: var(--highlight);
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--shadow-primary);
}

/* Duży przycisk dodawania (np. Nowa Grupa Ćwiczeń) */
.btn-add-group {
    width: 100%;
    padding: var(--space-lg);
    background: var(--bg-surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
}
.btn-add-group:hover {
    background: var(--bg-primary-alpha);
    border-color: var(--highlight);
    color: var(--highlight);
}

.btn-update {
    background: linear-gradient(135deg, #f39c12, #d35400) !important;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4) !important;
}

.btn-update:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.6) !important;
}

.d-none {
    display: none !important;
}

.position-relative {
    position: relative;
}

/* ==========================================================================
   3. INPUTY I FORMULARZE (FORMS)
   ========================================================================== */
.form-group, .input-group {
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.form-group label, .input-group label, .label {
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="email"], select, textarea, .cali-input, .cali-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-main);
    outline: none;
    transition: 0.3s;
}

input:focus, select:focus, textarea:focus, .cali-input:focus, .cali-select:focus {
    border-color: var(--highlight);
    background: var(--bg-surface-light);
    box-shadow: 0 0 0 3px var(--bg-primary-alpha);
}

.form-row {
    display: flex;
    gap: var(--space-md);
}
.form-row .form-group {
    flex: 1;
}

.hint-text {
    color: var(--text-muted);
    font-size: var(--text-xs);
    margin-top: var(--space-xs);
}

/* Common Footer Links */
.footer-links {
    margin-top: 8px;
    font-size: 0.8rem;
}

.footer-link {
    color: var(--highlight);
    text-decoration: underline;
}

/* Input typu "Parametr" (Małe liczby do serii i powtórzeń) */
.input-param {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-align: center;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-weight: var(--weight-bold);
}
.input-param:focus { border-color: var(--highlight); }

/* Notatki treningowe (Cienki pasek) */
.notes-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: var(--text-sm);
    padding: 4px 0;
    width: 100%;
}
.notes-input:focus { border-color: var(--highlight); }

/* ==========================================================================
   4. MODALE I ALERTY (MODALS & ALERTS)
   ========================================================================== */
.modal, .cali-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content, .calendar-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    width: 90%;
    max-width: 450px;
    box-shadow: var(--shadow-card);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
    transform: translateY(-20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.modal-header h2 {
    font-size: var(--text-xl);
    color: var(--text-main);
}

/* Alert Boxes (Success / Error) */
.message-box {
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: var(--text-sm);
    text-align: center;
    display: none;
    font-weight: var(--weight-medium);
}
.message-box.error {
    background: rgba(255, 77, 77, 0.1);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}
.message-box.success {
    background: rgba(46, 204, 113, 0.1);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

/* ==========================================================================
   5. WIDŻETY: PUSTY STAN (EMPTY STATE)
   ========================================================================== */
.empty-state-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-panel);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--space-xl);
    z-index: 10;
    border-radius: inherit;
}

.empty-state-panel i {
    font-size: 3.5rem;
    color: var(--border-color);
    margin-bottom: var(--space-md);
}

.empty-state-panel p {
    color: var(--text-muted);
    font-size: var(--text-base);
    margin-bottom: var(--space-lg);
    max-width: 80%;
}

/* ==========================================================================
   6. WIDŻETY: PROGRESS BAR & STATUSY
   ========================================================================== */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: calc(var(--progress-pct, 0) * 1%);
    background: hsl(var(--progress-hue, 270), 90%, 45%);
    border-radius: var(--radius-pill);
    transition: width 0.4s ease, background 0.4s ease;
}

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

.progress-text.is-active {
    color: var(--text-main);
}

.badge-series {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-circle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
    color: #fff !important;
}

/* ==========================================================================
   7. WIDŻETY: TOGGLE SWITCH (PRZEŁĄCZNIK)
   ========================================================================== */
.toggle-switch {
    position: relative;
    display: inline-flex;
    background: var(--bg-input);
    border-radius: var(--radius-pill);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.toggle-switch input { display: none; }

.toggle-label {
    display: flex;
    cursor: pointer;
    position: relative;
}

.toggle-label span {
    padding: 8px 18px;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    transition: color 0.3s ease;
    z-index: 2;
    min-width: 90px;
    text-align: center;
}

.toggle-label::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, var(--highlight), var(--accent-color));
    border-radius: var(--radius-pill);
    transition: left 0.3s ease;
    z-index: 1;
}

.toggle-switch input:checked + .toggle-label::after { left: 50%; }
.toggle-switch input:checked + .toggle-label .toggle-text-2 { color: #fff; }
.toggle-switch input:not(:checked) + .toggle-label .toggle-text-1 { color: #fff; }

/* ==========================================================================
   8. KOMPONENT KALENDARZA (MINI CALENDAR)
   ========================================================================== */
.calendar-controls { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: var(--space-md); 
}

.calendar-controls h3 { 
    font-size: var(--text-lg); 
    color: var(--highlight); 
    text-transform: uppercase; 
}

.cal-nav-btn {
    background: var(--bg-input); 
    border: 1px solid var(--border-light);
    color: var(--text-main); 
    width: 35px; height: 35px; 
    border-radius: var(--radius-sm); 
    cursor: pointer; 
}
.cal-nav-btn:hover { background: var(--bg-primary-alpha); border-color: var(--highlight); }

.calendar-container { 
    background: var(--bg-input); 
    border-radius: var(--radius-md); 
    padding: var(--space-md); 
    border: 1px solid var(--border-color);
}

.calendar-header-days, .calendar-grid {
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 5px; 
    text-align: center;
}

.calendar-header-days div { 
    font-size: var(--text-xs); 
    color: var(--text-muted); 
    font-weight: var(--weight-bold); 
    margin-bottom: var(--space-sm); 
}

.cal-day {
    aspect-ratio: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: var(--text-sm); 
    border-radius: var(--radius-sm); 
    color: var(--text-main);
    border: 1px solid transparent; 
    user-select: none;
}

.cal-day.empty { cursor: default; }

.cal-day.has-planned {
    background: var(--bg-primary-alpha); 
    border-color: var(--highlight); 
    cursor: pointer; 
    font-weight: var(--weight-bold);
}
.cal-day.has-planned:hover { background: var(--highlight); color: #fff; transform: scale(1.1); }

.cal-day.today {
    background: var(--highlight); 
    color: #fff;
    font-weight: var(--weight-bold);
}

.cal-day.has-completed {
    background: rgba(46, 204, 113, 0.15); 
    border-color: var(--color-success); 
    color: var(--color-success); 
    cursor: pointer; 
    font-weight: var(--weight-bold);
}
.cal-day.has-completed:hover { background: var(--color-success); color: #000; transform: scale(1.1); }

.cal-day.disabled-day { opacity: 0.3; cursor: not-allowed; }

.calendar-legend { 
    margin-top: var(--space-md); 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-sm); 
    font-size: var(--text-xs); 
    color: var(--text-muted); 
}

.legend-item { display: flex; align-items: center; gap: var(--space-sm); }
.legend-item .dot { width: 10px; height: 10px; border-radius: var(--radius-circle); }
.dot.planned { background: var(--highlight); }
.dot.completed { background: var(--color-success); }


/* ==========================================================================
   9. MODAL AKTUALIZACJI PRAWNEJ (LEGAL UPDATE MODAL)
   ========================================================================== */
.legal-update-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: rgba(15, 5, 24, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.legal-modal-content {
    background: var(--bg-surface);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    border: 1px solid var(--highlight);
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

.legal-icon {
    font-size: 3rem;
    color: var(--highlight);
    margin-bottom: 20px;
}

.legal-modal-title {
    margin-bottom: 15px;
    color: var(--text-main);
}

.legal-modal-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 25px;
}

.legal-agreements {
    margin-bottom: 25px;
    text-align: left;
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 10px;
}

.legal-checkbox-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.legal-checkbox-group:last-child {
    margin-bottom: 0;
}

.legal-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--highlight);
}

.legal-checkbox:disabled {
    cursor: not-allowed;
}

.legal-checkbox-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legal-link {
    color: var(--highlight);
    text-decoration: underline;
    font-weight: bold;
}

.legal-submit-btn {
    width: 100%;
    border-radius: 30px;
    padding: 14px;
    font-weight: bold;
}

/* ==========================================================================
   10. ELEMENTY UKŁADU (LAYOUT ELEMENTS)
   ========================================================================== */
.logo-area-link {
    text-decoration: none;
    color: inherit;
}

.topbar-welcome-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info-id-tag {
    color: #aaa;
    font-size: 0.7rem;
}

/* ==========================================================================
   11. POWIADOMIENIA (NOTIFICATIONS)
   ========================================================================== */
.notif-highlight-text {
    color: var(--highlight);
    font-weight: 700;
}

.notif-sender-nickname-info {
    font-size: 0.9rem;
}

.notif-sender-nickname-tag {
    color: #aaa;
    font-weight: 600;
}

.notif-system-header-container {
    font-weight: 700;
    color: var(--highlight);
    margin-bottom: 2px;
}

.notif-system-message-text {
    font-size: 0.85rem;
}

/* ==========================================================================
   12. PLAN RENDERER & SUMMARY
   ========================================================================== */
.flex-1 { flex: 1; }
.flex-1-5 { flex: 1.5; }

.summary-secondary-cell {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.chart-tooltip-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.chart-tooltip-result {
    font-size: 1.1em;
}

.chart-tooltip-hr {
    margin: 5px 0;
    border: 0;
    border-top: 1px solid;
}

.chart-tooltip-meta {
    font-size: 0.85rem;
}

.chart-tooltip-body {
    --tt-series-color: var(--text-main);
    --tt-value-color: var(--text-main);
    --tt-meta-color: var(--text-muted);
    --tt-hr-color: var(--border-light);
}

.chart-tooltip-body .chart-tooltip-title {
    color: var(--tt-series-color);
}

.chart-tooltip-body .chart-tooltip-result {
    color: var(--tt-value-color);
}

.chart-tooltip-body .chart-tooltip-meta,
.chart-tooltip-body .chart-tooltip-metric {
    color: var(--tt-meta-color);
}

.chart-tooltip-body .chart-tooltip-hr {
    border-color: var(--tt-hr-color);
}

/* ==========================================================================
   13. STANY UI (ładowanie, błędy, puste listy) — bez inline CSS w JS
   ========================================================================== */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.ui-grid-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
}

.ui-grid-message--error {
    color: var(--color-danger);
}

.ui-empty-grid-card {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.ui-empty-grid-card__icon {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.5;
    display: block;
}

.ui-empty-grid-card__btn {
    margin-top: 10px;
}

.search-result-empty {
    align-items: center;
    text-align: center;
    border-color: color-mix(in srgb, var(--color-danger) 40%, transparent);
}

.search-result-empty__icon {
    font-size: 3rem;
    color: var(--color-danger);
    margin-bottom: 10px;
}

.search-result-empty__title {
    color: var(--text-main);
    margin: 0;
    font-size: 1.2rem;
}

.search-result-empty__text {
    color: var(--text-muted);
    margin: 10px 0 0 0;
    font-size: 0.95rem;
}

.search-loading-block {
    text-align: center;
    color: var(--text-main);
    padding: 20px;
}

.empty-state-panel--in-grid {
    position: relative;
    padding: 60px 20px;
    background: color-mix(in srgb, var(--bg-main) 20%, transparent);
}

.empty-state-panel--in-grid .btn-primary-small {
    margin-top: 15px;
}

.band-dot {
    background-color: var(--band-color, var(--text-muted));
}

.profile-error-block {
    text-align: center;
    color: var(--color-danger);
    padding: 20px;
}

.avatar-loading-spinner {
    color: var(--text-main);
    font-size: 2rem;
}


/* --- BANER IMPERSONACJI TRENERA --- */
.trainer-impersonation-banner {
    position: relative; 
    z-index: 100; 
    background: rgba(30, 15, 50, 0.8); 
    border: 1px solid var(--highlight); 
    color: #fff; 
    padding: 15px 20px; 
    text-align: center; 
    border-radius: var(--radius-md); 
    margin: 0 20px var(--space-lg) 20px; 
    font-weight: var(--weight-semibold);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.trainer-impersonation-banner.banner-icon {
    color: var(--highlight); 
    font-size: 1.2rem; 
    margin-right: 10px;
}

.trainer-impersonation-banner.banner-text {
    font-size: 1.05rem; 
    letter-spacing: 0.5px;
}

.trainer-impersonation-banner.client-name-highlight {
    color: var(--highlight); 
    text-transform: uppercase;
}

/* --- STAN WYŁĄCZENIA PRZYCISKÓW --- */
button:disabled,.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}


/* Calendar RWD */
@media (max-width: 768px) {
    .calendar-container { padding: 10px; }
    .calendar-header-days div { font-size: 0.7rem; margin-bottom: 8px; }
    .cal-day { font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .calendar-controls h3 { font-size: 0.95rem; }
    .cal-nav-btn { width: 30px; height: 30px; font-size: 0.8rem; }
    .calendar-container { padding: 8px; }
    .calendar-header-days, .calendar-grid { gap: 3px; }
    .cal-day { font-size: 0.75rem; border-radius: 4px; }
}