/* History Page Styles */

/* Navigation Tabs */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 1rem;
    background: var(--surface-color, #1f2937);
    border-bottom: 1px solid var(--border-color, #374151);
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary, #9ca3af);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
}

.main-nav a:hover {
    color: var(--text-primary, #f3f4f6);
    background: rgba(255, 255, 255, 0.05);
}

.main-nav a.active {
    color: var(--primary-color, #d95555);
    border-bottom-color: var(--primary-color, #d95555);
}

.main-nav .nav-icon {
    font-size: 1.1rem;
}

/* History Page Layout */
.history-page {
    max-width: 100%;
    margin: 0;
    padding: 0;
    min-height: calc(100vh - 200px);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
    margin: 0;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface-color, #1f2937);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color, #374151);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    font-size: 2rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #f3f4f6);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary, #9ca3af);
}

/* History Content */
.history-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Daily View */
.daily-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease-in-out;
}

.date-navigator-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
}

/* Weekly View */
.weekly-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease-in-out;
}

.weekly-chart-section {
    background: var(--surface-color, #1f2937);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color, #374151);
}

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

.timeline-section,
.chart-section {
    background: var(--surface-color, #1f2937);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color, #374151);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
    margin: 0;
}

.activity-count {
    font-size: 0.75rem;
    color: var(--text-secondary, #9ca3af);
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Date Navigator */
.date-navigator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 36px;
    gap: 1rem;
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.nav-btn {
    background: var(--surface-color, #1f2937);
    border: 1px solid var(--border-color, #374151);
    color: var(--text-secondary, #9ca3af);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.current-date {
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-primary, #f3f4f6);
    flex-grow: 1;
    text-align: left;
}

.nav-btn:hover:not(:disabled) {
    background: var(--border-color, #374151);
    color: var(--text-primary, #f3f4f6);
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 4px 15px var(--glow-secondary),
                0 2px 6px var(--glow-secondary-secondary);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Timeline Scroll Container - contains timeline and sentinel */
.timeline-scroll-container {
    max-height: 400px;
    overflow-y: auto;
    position: relative;
}

.activity-item {
    display: grid;
    grid-template-columns: 2rem 3.5rem 1fr 3rem;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.activity-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.activity-icon {
    font-size: 1.25rem;
    text-align: center;
}

.activity-time {
    font-size: 0.875rem;
    color: var(--text-secondary, #9ca3af);
    font-family: monospace;
}

.activity-name {
    font-size: 0.875rem;
    color: var(--text-primary, #f3f4f6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-duration {
    font-size: 0.75rem;
    color: var(--text-secondary, #9ca3af);
    text-align: right;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-secondary, #9ca3af);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
    font-size: 0.875rem;
}

/* Weekly Chart */
.weekly-chart {
    height: 200px;
    position: relative;
}

/* Time Distribution Chart */
.time-distribution-section {
    background: var(--surface-color, #1f2937);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color, #374151);
}

.time-distribution-chart {
    display: flex;
    flex-direction: column;
}

.time-distribution-chart .chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
    margin: 0 0 1rem 0;
    text-align: left;
}

.time-distribution-chart .chart-container {
    width: 100%;
    height: 200px;
    position: relative;
    min-height: 180px;
}

.time-distribution-chart .chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.time-distribution-chart .chart-summary {
    margin-top: 0.75rem;
    text-align: center;
}

.time-distribution-chart .total-time {
    font-size: 0.875rem;
    color: var(--text-secondary, #9ca3af);
    font-weight: 500;
}

.time-distribution-chart .empty-chart-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: var(--text-secondary, #9ca3af);
}

.time-distribution-chart .empty-chart-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.time-distribution-chart .empty-chart-state p {
    margin: 0;
    font-size: 0.875rem;
}

/* Weekly Summary Section */
.weekly-summary-section {
    background: var(--surface-color, #1f2937);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color, #374151);
}

.weekly-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.weekly-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.weekly-stats .stat:hover {
    transform: translateY(-2px);
}

.weekly-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #f3f4f6);
    margin-bottom: 0.25rem;
}

.weekly-stats .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.weekly-stats .stat.trend {
    border: 1px solid;
    border-radius: 8px;
}

.weekly-stats .stat.trend.positive {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.weekly-stats .stat.trend.positive .stat-value {
    color: #10b981;
}

.weekly-stats .stat.trend.negative {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.weekly-stats .stat.trend.negative .stat-value {
    color: #ef4444;
}

/* Load More Button */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
    padding: 1rem 0;
}

.load-more-button {
    background: var(--surface-color, #1f2937);
    border: 1px solid var(--border-color, #374151);
    color: var(--text-primary, #f3f4f6);
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.load-more-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary, #9ca3af);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 4px 15px var(--glow-secondary),
                0 2px 6px var(--glow-secondary-secondary);
}

.load-more-button:active:not(:disabled) {
    transform: scale(1.02) translateY(0);
}

.load-more-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .history-page {
        padding: 1rem;
    }
    
    .history-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .main-nav a {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .main-nav a span:last-child {
        display: none;
    }
    
    .main-nav .nav-icon {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        font-size: 1.5rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .activity-item {
        grid-template-columns: 2rem 3rem 1fr 2.5rem;
        gap: 0.5rem;
        padding: 0.5rem;
    }
}

/* Infinite Scroll Styles */
.scroll-sentinel {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80px;
    padding: 16px;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pomodoro-loader {
    position: relative;
    width: 40px;
    height: 40px;
    animation: pomodoroBounce 0.8s ease-in-out infinite;
}

.tomato-body {
    position: relative;
    width: 40px;
    height: 40px;
    background-color: #d95555;
    border-radius: 50%;
    animation: tomatoSquash 0.8s ease-in-out infinite;
}

.tomato-leaf {
    position: absolute;
    width: 12px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.tomato-leaf-left {
    top: -4px;
    left: 6px;
    transform: rotate(-30deg);
    animation: leafBounceLeft 0.8s ease-in-out infinite;
}

.tomato-leaf-right {
    top: -4px;
    right: 6px;
    transform: rotate(30deg);
    animation: leafBounceRight 0.8s ease-in-out infinite;
}

.tomato-shadow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 6px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    animation: shadowScale 0.8s ease-in-out infinite;
}

@keyframes pomodoroBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes tomatoSquash {
    0%, 100% {
        transform: scale(1, 1);
    }
    50% {
        transform: scale(1.1, 0.9);
    }
}

@keyframes leafBounceLeft {
    0%, 100% {
        transform: rotate(-30deg) translateY(0);
    }
    50% {
        transform: rotate(-35deg) translateY(-5px);
    }
}

@keyframes leafBounceRight {
    0%, 100% {
        transform: rotate(30deg) translateY(0);
    }
    50% {
        transform: rotate(35deg) translateY(-5px);
    }
}

@keyframes shadowScale {
    0%, 100% {
        transform: translateX(-50%) scale(1);
        opacity: 0.2;
    }
    50% {
        transform: translateX(-50%) scale(0.6);
        opacity: 0.1;
    }
}

.end-of-list {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    color: var(--text-secondary, #9ca3af);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color, #374151);
    margin-top: 16px;
}
