@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    /* MD3 Dark Theme - Meditation (původní tmavé barvy) */
    --md-sys-color-primary: #667eea;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #283593;
    --md-sys-color-on-primary-container: #e8eaf6;

    --md-sys-color-secondary: #764ba2;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #4a148c;
    --md-sys-color-on-secondary-container: #e1bee7;

    --md-sys-color-tertiary: #ef5350;

    --md-sys-color-background: #1a1a2e;
    --md-sys-color-on-background: #eeeef0;

    --md-sys-color-surface: #16213e;
    --md-sys-color-on-surface: #eeeef0;
    --md-sys-color-surface-variant: #0f1624;
    --md-sys-color-on-surface-variant: #bbbbc0;
    --md-sys-color-outline: #8e9099;
    --md-sys-color-outline-variant: #44474f;

    --md-sys-color-success: #4ade80;
    --md-sys-color-error: #ef4444;
    --md-sys-color-on-error: #ffffff;

    /* MD3 Elevations */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);

    /* Layout & Shape */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 28px;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

/* Light Mode Variables (volitelné) */
body.light-mode {
    --md-sys-color-primary: #3f51b5;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #e8eaf6;
    --md-sys-color-on-primary-container: #1a237e;

    --md-sys-color-secondary: #009688;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e0f2f1;
    --md-sys-color-on-secondary-container: #004d40;

    --md-sys-color-background: #fdfbff;
    --md-sys-color-on-background: #1b1b1f;

    --md-sys-color-surface: #fdfbff;
    --md-sys-color-on-surface: #1b1b1f;
    --md-sys-color-surface-variant: #e1e2ec;
    --md-sys-color-on-surface-variant: #44474f;
    --md-sys-color-outline: #74777f;
    --md-sys-color-outline-variant: #c4c6d0;

    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
}

/* Theme Toggle Transitions */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.card, .stat-card, .app-bar, .tabs-container {
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

@keyframes themeSwitch {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

body.theme-switching {
    animation: themeSwitch 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* === Material Symbols === */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* === Layout === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    background-color: var(--md-sys-color-background);
}

/* === App Bar === */
.app-bar {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-top: max(var(--spacing-sm), env(safe-area-inset-top));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    z-index: 10;
    transition: background-color 0.3s;
}

.app-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.app-title-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.app-logo {
    color: var(--md-sys-color-primary);
    font-size: 28px;
}

.app-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin: 0;
}

.app-version-badge {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.app-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.icon-button:active {
    background-color: var(--md-sys-color-surface-variant);
}

/* === Tabs === */
.tabs-container {
    background-color: var(--md-sys-color-surface);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    overflow: hidden;
    order: 3;
}

.tabs-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom);
}

.tabs-scroll {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs-scroll::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 1;
    min-width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--spacing-sm) var(--spacing-sm);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-label {
    font-size: 12px;
    font-weight: 500;
}

.tab.active {
    color: var(--md-sys-color-primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--md-sys-color-primary);
    border-radius: 0 0 3px 3px;
}

/* === Main Content === */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* === Cards === */
.card {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--md-sys-elevation-1);
    margin-bottom: var(--spacing-md);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 10px var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
    touch-action: manipulation;
}

.btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: var(--md-sys-elevation-2);
}

.btn-secondary {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-secondary:active {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
}

.btn-danger {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.btn-danger:active {
    opacity: 0.9;
}

.hidden {
    display: none !important;
}

/* === Duration Selector === */
.duration-selector {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    margin: var(--spacing-sm) 0;
    flex-wrap: wrap;
}

.duration-btn {
    padding: 8px var(--spacing-sm);
    background-color: var(--md-sys-color-surface-variant);
    border: 2px solid transparent;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 55px;
}

.duration-btn.active {
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-primary-container);
}

.duration-btn:active {
    transform: scale(0.95);
}

/* === Audio Controls === */
.audio-controls h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 16px;
    margin-bottom: var(--spacing-md);
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.audio-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.audio-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.audio-option:has(input:checked) {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.audio-option input[type="radio"] {
    display: none;
}

.audio-option .material-symbols-outlined {
    font-size: 32px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.volume-control input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--md-sys-color-surface-variant);
    outline: none;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    cursor: pointer;
    box-shadow: var(--md-sys-elevation-1);
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    cursor: pointer;
    border: none;
    box-shadow: var(--md-sys-elevation-1);
}

#volumeValue {
    min-width: 45px;
    text-align: right;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    font-size: 14px;
}

/* === Stats View === */
.stats-container {
    padding: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.stat-card {
    background-color: var(--md-sys-color-surface);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--md-sys-elevation-1);
    transition: transform 0.2s;
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-icon {
    font-size: 40px !important;
    color: var(--md-sys-color-primary);
    margin-bottom: var(--spacing-xs);
}

.stat-content {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
    justify-content: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.stat-trend {
    font-size: 14px;
    font-weight: 600;
}

.stat-trend.up {
    color: #4caf50;
}

.stat-trend.down {
    color: #f44336;
}

.stat-trend.neutral {
    color: var(--md-sys-color-on-surface-variant);
}

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

.stat-value.updating {
    animation: countUp 0.5s ease;
}

.stat-label {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

.progress-section h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 18px;
    margin-bottom: var(--spacing-md);
    text-align: left;
    font-weight: 500;
}

.progress-badge {
    text-align: center;
    padding: var(--spacing-md) 0;
}

.badge-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-sm);
}

.badge-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    margin-bottom: var(--spacing-xs);
}

.badge-desc {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
}

/* === Weekly Chart === */
.weekly-chart-section h3,
.calendar-section h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 18px;
    margin-bottom: var(--spacing-md);
    text-align: left;
    font-weight: 500;
}

.chart-container {
    position: relative;
    height: 200px;
    padding: var(--spacing-sm);
}

.chart-bar {
    fill: var(--md-sys-color-primary);
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.chart-bar:hover {
    opacity: 0.8;
}

.chart-bar.today {
    fill: var(--md-sys-color-secondary);
}

.chart-label {
    fill: var(--md-sys-color-on-surface-variant);
    font-size: 11px;
}

.chart-value {
    fill: var(--md-sys-color-on-surface);
    font-size: 10px;
    font-weight: 500;
}

.chart-axis, .chart-grid {
    stroke: var(--md-sys-color-outline-variant);
}

.chart-grid {
    stroke-width: 0.5;
    opacity: 0.3;
}

/* === Calendar Heatmap === */
.calendar-heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-md);
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background-color: var(--md-sys-color-surface-variant);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--md-sys-color-outline-variant);
    position: relative;
}

.calendar-day:hover {
    transform: scale(1.1);
    z-index: 1;
    box-shadow: var(--md-sys-elevation-2);
}

.calendar-day.level-0 {
    background-color: var(--md-sys-color-surface-variant);
    opacity: 0.3;
}

.calendar-day.level-1 {
    background-color: var(--md-sys-color-primary);
    opacity: 0.2;
}

.calendar-day.level-2 {
    background-color: var(--md-sys-color-primary);
    opacity: 0.4;
}

.calendar-day.level-3 {
    background-color: var(--md-sys-color-primary);
    opacity: 0.7;
}

.calendar-day.level-4 {
    background-color: var(--md-sys-color-primary);
    opacity: 1;
}

.calendar-day.today {
    border: 2px solid var(--md-sys-color-primary);
}

.calendar-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: nowrap;
    box-shadow: var(--md-sys-elevation-2);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 10;
    margin-bottom: 4px;
}

.calendar-day:hover .calendar-tooltip {
    opacity: 1;
}

.calendar-legend {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    justify-content: center;
}

.legend-scale {
    display: flex;
    gap: 3px;
}

.legend-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.legend-box.level-0 {
    background-color: var(--md-sys-color-surface-variant);
    opacity: 0.3;
}

.legend-box.level-1 {
    background-color: var(--md-sys-color-primary);
    opacity: 0.2;
}

.legend-box.level-2 {
    background-color: var(--md-sys-color-primary);
    opacity: 0.4;
}

.legend-box.level-3 {
    background-color: var(--md-sys-color-primary);
    opacity: 0.7;
}

.legend-box.level-4 {
    background-color: var(--md-sys-color-primary);
    opacity: 1;
}

@media (max-width: 380px) {
    .calendar-heatmap {
        gap: 3px;
    }

    .calendar-legend {
        font-size: 11px;
    }

    .legend-box {
        width: 14px;
        height: 14px;
    }
}

/* === Settings View === */
.settings-container {
    padding: 0;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.settings-group select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-sm);
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    cursor: pointer;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.checkbox-label input[type="checkbox"] {
    margin-right: var(--spacing-sm);
    accent-color: var(--md-sys-color-primary);
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-icon {
    margin-right: var(--spacing-xs);
}

.settings-group h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-size: 16px;
    font-weight: 500;
}

.info-text {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: var(--spacing-xs);
}

/* Update Status */
.update-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-md);
    font-size: 14px;
}

.update-status.success {
    background-color: rgba(74, 222, 128, 0.2);
    color: var(--md-sys-color-success);
}

.update-status.warning {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

/* Timer containers */
.timer-container {
    padding: 0;
}

.timer-controls {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--spacing-md);
}

/* Breathing containers */
.breathing-container {
    padding: 0;
}

.breathing-controls {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-top: var(--spacing-md);
}
