/* Import Zalando Sans Expanded Font */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&display=swap');

/* Using Sora as fallback - for actual Zalando Sans Expanded, you'd need to host it */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --red-0: #fff5f5;
    --red-1: #ffcccb;
    --red-2: #ff9999;
    --red-3: #ff6666;
    --red-4: #cc0000;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navbar */
.navbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--text-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1.1rem;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--text-primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.logout-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: var(--bg-tertiary);
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

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

.page.active {
    display: block;
}

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

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

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Reset Button */
.reset-btn {
    padding: 0.625rem 1.25rem;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.reset-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.reset-btn:active {
    transform: translateY(0);
}

/* Calendar Layout */
.calendar-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 968px) {
    .calendar-layout {
        grid-template-columns: 1fr;
    }
}

/* Calendar Section */
.calendar-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 80px;
}

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

.calendar-month {
    font-size: 1.25rem;
    font-weight: 600;
}

.calendar-nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-label {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-date {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    border: 2px solid transparent;
}

.calendar-date:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.calendar-date.other-month {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.calendar-date.today {
    background: var(--bg-secondary);
    border-color: var(--text-primary);
    font-weight: 700;
}

.calendar-date.selected {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.calendar-date.has-plan::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--red-3);
}

.calendar-date.selected.has-plan::after {
    background: var(--bg-primary);
}

.calendar-date-completion {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.calendar-date.selected .calendar-date-completion {
    color: rgba(255, 255, 255, 0.7);
}

/* Date Panel */
.date-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
}

.date-panel-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.date-panel-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.status-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.planning-open {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.check-open {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge.locked {
    background: var(--red-0);
    color: #c62828;
}

/* Panel Sections */
.panel-section {
    margin-bottom: 2.5rem;
}

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

.section-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.section-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Combobox */
.combobox-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.activity-combobox {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.activity-combobox:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.activity-combobox:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
    display: none;
}

.suggestions-dropdown.active {
    display: block;
    animation: dropdownSlide 0.2s ease;
}

.suggestion-item {
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--bg-secondary);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-secondary);
}

.suggestion-item.create-new {
    color: var(--text-primary);
    font-weight: 600;
    background: var(--bg-secondary);
}

.suggestion-item.create-new:hover {
    background: var(--bg-tertiary);
}

/* Activities List */
.activities-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 100px;
}

/* Completion Summary */
.completion-summary {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.summary-stats {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.completed-count {
    font-size: 1.5rem;
    font-weight: 700;
}

.completion-percentage {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    animation: itemFadeIn 0.3s ease;
}

@keyframes itemFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.activity-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    transform: translateX(2px);
}

.activity-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.activity-checkbox.checked {
    background: var(--text-primary);
    border-color: var(--text-primary);
    animation: checkPop 0.3s ease;
}

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

.activity-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.activity-checkbox.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.activity-item.readonly {
    cursor: default;
}

.activity-item.readonly:hover {
    transform: none;
}

.activity-name {
    flex: 1;
    font-size: 0.95rem;
}

.activity-item.completed .activity-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.activity-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.activity-item:hover .activity-actions {
    opacity: 1;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    font-size: 1.1rem;
}

.action-btn:hover {
    color: var(--text-primary);
}

.drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    font-size: 1.1rem;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Save Status */
.save-status {
    margin-top: 1rem;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.save-status.show {
    opacity: 1;
}

/* Backlog Items */
.backlog-item {
    background: var(--red-0);
    border: 1px solid var(--red-1);
}

.backlog-item:hover {
    background: var(--red-1);
}

.backlog-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-left: auto;
    margin-right: 0.5rem;
}

.backlog-btn {
    margin-left: auto;
    color: var(--red-3);
    font-size: 1rem;
}

.backlog-btn:hover {
    color: var(--red-4);
}

.complete-backlog-btn {
    color: #2e7d32;
    font-size: 1.1rem;
}

.complete-backlog-btn:hover {
    color: #1b5e20;
}

/* Dashboard Stats */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Heatmap */
.heatmap-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

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

.heatmap-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-tile {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
}

.legend-tile.level-0 {
    background: var(--red-0);
}

.legend-tile.level-1 {
    background: var(--red-1);
}

.legend-tile.level-2 {
    background: var(--red-2);
}

.legend-tile.level-3 {
    background: var(--red-3);
}

.legend-tile.level-4 {
    background: var(--red-4);
}

.heatmap-grid {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 1rem 0;
    position: relative;
}

.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.month-labels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.month-label {
    position: absolute;
    white-space: nowrap;
}

.heatmap-tile {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.heatmap-tile.empty {
    opacity: 0;
    pointer-events: none;
}

.heatmap-tile.future {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none; /* Completely disable clicking */
}

.heatmap-tile.today {
    box-shadow: 0 0 0 2px var(--text-primary);
}

.heatmap-tile:not(.empty):not(.future):hover {
    transform: scale(1.3);
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.heatmap-tile.level-0 {
    background: var(--red-0);
}

.heatmap-tile.level-1 {
    background: var(--red-1);
}

.heatmap-tile.level-2 {
    background: var(--red-2);
}

.heatmap-tile.level-3 {
    background: var(--red-3);
}

.heatmap-tile.level-4 {
    background: var(--red-4);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    animation: tooltipFade 0.2s ease;
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: overlayFade 0.3s ease;
}

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

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.modal-body {
    padding: 2rem;
}

.modal-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.modal-score {
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-completion {
    font-size: 1rem;
    color: var(--text-secondary);
}

.modal-activities {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-activity-item.completed {
    opacity: 0.7;
}

.modal-activity-item.completed .modal-activity-name {
    text-decoration: line-through;
}

.modal-activity-item .activity-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--text-primary);
    flex-shrink: 0;
}

.modal-activity-item .activity-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.modal-activity-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
}

.modal-activity-item.completed .modal-activity-status {
    background: var(--text-primary);
}

.modal-activity-name {
    flex: 1;
    font-size: 0.95rem;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    padding: 2rem;
}

.login-card {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.google-login-btn {
    width: 100%;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    font-family: 'Sora', sans-serif;
}

.google-login-btn:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.google-login-btn:active {
    transform: translateY(0);
}

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

.google-icon {
    flex-shrink: 0;
}

.login-error {
    margin-top: 1rem;
    padding: 1rem;
    background: #ffebee;
    color: #c62828;
    border-radius: 6px;
    font-size: 0.9rem;
}

.login-loading {
    margin-top: 1rem;
    padding: 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

    .nav-container {
        padding: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .heatmap-container {
        padding: 1.5rem;
        overflow-x: auto;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header,
    .modal-body {
        padding: 1.5rem;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}
