/* --- GŁÓWNE RESETOWANIE I ZMIENNE --- */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #311042 100%);
    --card-bg: rgba(30, 41, 59, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #a855f7;
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
}

.light-theme {
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
    --card-bg: rgba(255, 255, 255, 0.65);
    --card-border: rgba(15, 23, 42, 0.08);
    --text-primary: #0f172a;
    --text-muted: #475569;
    --accent-color: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition-speed), color var(--transition-speed);
}

/* --- LOADER EKRANU POWITALNEGO --- */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-gradient);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.loader-container.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    animation: fadeIn 1s ease;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--card-border);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

.loader-content h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

/* --- EFEKT GLASSMORPHISM --- */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

/* --- KONTENER UKŁADU --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- PANEL BOCZNY (SIDEBAR) --- */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 15px;
    left: 15px;
    bottom: 15px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 100;
    transition: transform var(--transition-speed);
}

.brand {
    margin-bottom: 40px;
}

.brand h2 {
    font-size: 1.8rem;
    font-weight: 800;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    background: var(--accent-gradient);
    color: white;
    margin-top: 6px;
}

.badge-info {
    background: var(--card-border);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 14px 18px;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.nav-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.action-btn-mini {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.action-btn-mini:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- OBSZAR GŁÓWNY (MAIN CONTENT) --- */
.main-content {
    margin-left: calc(var(--sidebar-width) + 30px);
    flex-grow: 1;
    padding: 30px 30px 30px 15px;
    max-width: 1400px;
}

.app-section {
    display: none;
    animation: fadeInUp 0.4s ease forwards;
}

.app-section.active {
    display: block;
}

.section-header {
    margin-bottom: 30px;
}

.section-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.section-header p {
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- BANER POWIADOMIEŃ --- */
.alert-banner {
    background: var(--accent-gradient);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    font-weight: 600;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    animation: shake 0.5s ease;
}

.alert-banner.hidden {
    display: none;
}

/* --- KARTY I ELEMENTY INTERFEJSU --- */
.card-container {
    padding: 24px;
    margin-bottom: 25px;
}

.card-container h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.margin-top {
    margin-top: 25px;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

hr {
    border: 0;
    height: 1px;
    background: var(--card-border);
    margin: 20px 0;
}

/* --- SIATKA STATYSTYK --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-icon {
    font-size: 2.2rem;
    background: rgba(255, 255, 255, 0.05);
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 14px;
    border: 1px solid var(--card-border);
}

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 800;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* --- CELE DZIENNE (SUWAKI Z WŁASNYM STYLEM) --- */
.goal-item {
    margin-bottom: 20px;
}

.goal-label {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* --- PRZYCISKI --- */
.btn {
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.label-btn {
    display: inline-block;
    text-align: center;
}

/* --- TIMER --- */
.timer-display {
    font-size: 3.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin: 15px 0;
    letter-spacing: -1px;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.timer-controls, .timer-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.hidden {
    display: none !important;
}

/* --- SEKCJA TRENINGÓW --- */
.workout-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tab-btn:hover, .tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tab-btn.active {
    border-color: var(--accent-color);
    background: rgba(168, 85, 247, 0.15);
}

.workout-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}


.workout-note {
    color: var(--text-muted);
    line-height: 1.5;
    margin: -4px 0 18px;
}

.workout-stopwatch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    margin-bottom: 16px;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.035);
}

.workout-stopwatch > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.workout-stopwatch-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.workout-stopwatch-display {
    color: var(--accent-color);
    font-size: 2rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

.workout-stopwatch-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.workout-plan-tip {
    padding: 14px 16px;
    margin-bottom: 22px;
    border-left: 4px solid var(--accent-color);
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.08);
    color: var(--text-muted);
    line-height: 1.5;
}

.workout-plan-tip strong {
    color: var(--text-primary);
}

/* PASEK POSTĘPU */
.progress-wrapper {
    margin-bottom: 25px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.progress-bar-bg {
    background: rgba(255, 255, 255, 0.08);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--success-color);
    height: 100%;
    width: 0%;
    border-radius: 6px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LISTA ĆWICZEŃ */
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 30px;
}

.exercise-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    transition: all 0.25s ease;
}

.exercise-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.exercise-item.checked {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
}

.ex-details h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
    transition: color 0.2s;
}

.exercise-item.checked .ex-details h4 {
    text-decoration: line-through;
    color: var(--text-muted);
}

.ex-details p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ŁADNE CHECKBOXY */
.checkbox-container {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 28px;
    width: 28px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--card-border);
    border-radius: 8px;
    transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: rgba(255, 255, 255, 0.15);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 9px;
    top: 5px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/* --- FORMULARZE I KONTROLI --- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--accent-color);
}

select.form-control option {
    background: #1e1b4b;
    color: white;
}

/* --- TABELE --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th, td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
}

th {
    font-weight: 700;
    color: var(--text-muted);
}

/* --- SIATKA KALENDARZA --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.calendar-day-box {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.calendar-day-box.completed {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success-color);
    color: var(--success-color);
}

.calendar-day-box.current-week {
    border-color: var(--accent-color);
    background: rgba(168, 85, 247, 0.05);
}

.calendar-day-box span {
    font-size: 0.65rem;
    font-weight: 500;
    margin-top: 2px;
}

/* --- WYKRESY FALLBACK (BEZ BIBLIOTEK) --- */
.charts-fallback {
    display: flex;
    gap: 20px;
    justify-content: space-around;
    flex-wrap: wrap;
}

.chart-column {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.chart-column h3 {
    font-size: 0.95rem;
    margin-bottom: 15px;
    color: var(--text-muted);
}

.custom-bar-chart {
    height: 140px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 2px solid var(--card-border);
    padding: 10px;
    border-radius: 8px;
}

.chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.chart-bar {
    width: 100%;
    background: var(--accent-gradient);
    border-radius: 4px 4px 0 0;
    min-height: 5px;
    transition: height 0.5s ease;
    display: flex;
    justify-content: center;
}

.chart-val {
    font-size: 0.65rem;
    margin-top: -16px;
    font-weight: 700;
}

.chart-lbl {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- WYSZUKIWANIE I FILTRY --- */
.search-filter-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.search-filter-row input {
    flex: 2;
}
.search-filter-row select {
    flex: 1;
}

/* --- OKNA DIALOGOWE MODALE --- */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-box {
    max-width: 450px;
    width: 100%;
    padding: 30px;
    animation: zoomIn 0.3s ease forwards;
}

.modal-box h2 {
    margin-bottom: 12px;
    font-size: 1.4rem;
}

.modal-box p {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

/* --- ANIMACJE --- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* --- RESPONSYWNOŚĆ (MEDIA QUERIES) --- */
@media (max-width: 992px) {
    .sidebar {
        width: 70px;
        padding: 15px 10px;
    }
    .brand h2, .brand .badge, .nav-btn {
        font-size: 0;
    }
    .nav-btn {
        justify-content: center;
        padding: 15px 0;
    }
    .nav-btn:after {
        content: attr(data-target);
        display: none;
    }
    /* Pokazuj tylko emoji ikonę jako skrót */
    .nav-btn {
        font-size: 1.3rem;
    }
    .sidebar-footer {
        display: none;
    }
    .main-content {
        margin-left: 85px;
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        padding: 15px;
        margin: 0;
        border-radius: 0;
        border-width: 0 0 1px 0;
    }
    .brand {
        margin-bottom: 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .brand h2 {
        font-size: 1.4rem;
    }
    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 5px;
        gap: 8px;
    }
    .nav-btn {
        font-size: 0.9rem;
        padding: 8px 14px;
        white-space: nowrap;
    }
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    .dashboard-split {
        grid-template-columns: 1fr;
    }
    .timer-display {
        font-size: 2.8rem;
    }
    .workout-stopwatch {
        align-items: stretch;
        flex-direction: column;
    }
    .workout-stopwatch-actions .btn {
        flex: 1;
    }
    .workout-stopwatch-display {
        font-size: 1.8rem;
    }
}
