/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

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

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.tagline {
    opacity: 0.9;
    font-size: 1rem;
}

/* Main content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    width: 100%;
}

/* Panel styles */
.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Session panel */
.session-controls {
    text-align: center;
}

.timer-display {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    font-size: 3rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.session-status {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.session-status.active {
    color: var(--success-color);
}

.task-input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.task-input-group input,
.task-input-group select {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.task-input-group input:focus,
.task-input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: #cbd5e1;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Distraction section */
.distraction-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.distraction-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.distraction-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.distraction-input-group input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.distraction-input-group input:focus {
    outline: none;
    border-color: var(--warning-color);
}

.distractions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.distraction-tag {
    background: #fef3c7;
    color: #92400e;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.distraction-tag .time {
    opacity: 0.7;
    font-size: 0.7rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* History section */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.history-header h2 {
    margin-bottom: 0;
}

.history-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.history-controls select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    gap: 1rem;
    flex-wrap: wrap;
}

.session-info {
    flex: 1;
    min-width: 200px;
}

.session-task {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.session-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.session-category {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.category-work { background: #dbeafe; color: #1e40af; }
.category-study { background: #dcfce7; color: #166534; }
.category-creative { background: #fae8ff; color: #86198f; }
.category-personal { background: #fed7aa; color: #9a3412; }
.category-exercise { background: #ccfbf1; color: #115e59; }
.category-other { background: #e2e8f0; color: #475569; }

.session-stats {
    text-align: right;
    min-width: 100px;
}

.session-duration {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.session-distractions {
    font-size: 0.8rem;
    color: var(--warning-color);
}

.session-actions {
    display: flex;
    gap: 0.5rem;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    transition: color 0.2s;
}

.delete-btn:hover {
    color: var(--danger-color);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Metrics section */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: linear-gradient(135deg, var(--bg-color) 0%, #f1f5f9 100%);
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-color);
}

.metric-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.chart-container {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
}

.chart-container h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.chart-container canvas {
    width: 100% !important;
    height: 200px !important;
}

/* Habits section */
.habits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.habit-card {
    background: linear-gradient(135deg, var(--bg-color) 0%, #f1f5f9 100%);
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.habit-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.habit-card p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.habit-insights {
    margin-bottom: 1.5rem;
}

.habit-insights h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.heatmap-container {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 0.75rem;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    min-height: 24px;
}

.heatmap-header {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-0 { background: #e2e8f0; }
.level-1 { background: #c7d2fe; }
.level-2 { background: #a5b4fc; }
.level-3 { background: #818cf8; }
.level-4 { background: #6366f1; }

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-colors {
    display: flex;
    gap: 2px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.common-distractions h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.distraction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.distraction-name {
    font-weight: 500;
}

.distraction-count {
    background: var(--warning-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: auto;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.footer a:hover {
    color: #818cf8;
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .timer-display {
        font-size: 2rem;
        padding: 1rem 1.5rem;
    }

    .task-input-group {
        flex-direction: column;
    }

    .task-input-group input,
    .task-input-group select {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .history-header {
        flex-direction: column;
        align-items: stretch;
    }

    .history-controls {
        justify-content: space-between;
    }

    .session-item {
        flex-direction: column;
    }

    .session-stats {
        text-align: left;
        width: 100%;
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .tabs {
        justify-content: stretch;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem 0.75rem;
    }

    .panel {
        padding: 1rem;
        border-radius: var(--radius-sm);
    }

    .timer-display {
        font-size: 1.75rem;
    }

    .metric-value {
        font-size: 1.4rem;
    }

    .habits-grid {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.session-status.active {
    animation: pulse 2s ease-in-out infinite;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}
