/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.4;
    overflow-x: hidden;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Header */
.header {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.3);
}

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

.week-title {
    flex: 1;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
}

.today-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.today-btn:hover {
    background: rgba(255,255,255,0.3);
}

.settings-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Main Content */
.main {
    flex: 1;
    padding: 1rem;
}

.view {
    animation: fadeIn 0.3s ease;
}

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

/* Week View */
.days-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.day-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.day-card.today {
    border: 2px solid #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.day-card.today:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.day-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.day-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.day-date {
    color: #666;
    font-size: 0.9rem;
}

.day-summary {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.activity-chip {
    background: #e8f5e8;
    color: #2e7d2e;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Day View */
.day-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.back-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #45a049;
}

.day-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.swim-lanes-container {
    background: white;
    border-radius: 12px;
    overflow: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 70vh;
}

.swim-lanes-grid {
    display: flex;
    min-width: max-content;
}

.timeline-column {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #f8f9fa;
    border-right: 2px solid #e9ecef;
    min-width: 80px;
}

.timeline-header {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    border-bottom: 1px solid #e9ecef;
    background: #f1f3f4;
}

.timeline-hours {
    display: flex;
    flex-direction: column;
}

.hour-marker {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #666;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    min-width: 80px;
}

.hour-marker:last-child {
    border-bottom: none;
}

.swim-lanes {
    display: flex;
    flex-direction: row;
    flex: 1;
}

.swim-lane {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    border-right: 1px solid #e9ecef;
    position: relative;
}

.swim-lane:last-child {
    border-right: none;
}

.lane-label {
    height: 50px;
    padding: 0 1rem;
    font-weight: 500;
    background: #f1f3f4;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 3;
}

.lane-content {
    flex: 1;
    position: relative;
    min-height: 960px;
    cursor: pointer;
}

.lane-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.grid-hour {
    flex: 1;
    border-bottom: 1px solid #e9ecef;
    opacity: 0.3;
    height: 40px;
}

.grid-hour:last-child {
    border-bottom: none;
}

.activity-block {
    position: absolute;
    left: 4px;
    right: 4px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 2;
    min-height: 20px;
}

.activity-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.activity-block.grade-1 {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.activity-block.grade-2 {
    background: linear-gradient(135deg, #FFC107, #FFB300);
}

.activity-block.grade-3 {
    background: linear-gradient(135deg, #FF9800, #F57400);
}

.activity-block.grade-4 {
    background: linear-gradient(135deg, #F44336, #D32F2F);
}

/* Settings View */
.settings-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.setting-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.setting-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.setting-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.setting-item-name {
    flex: 1;
    font-weight: 500;
}

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

.edit-item-btn, .delete-item-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.edit-item-btn {
    color: #4CAF50;
}

.edit-item-btn:hover {
    background: #e8f5e8;
}

.delete-item-btn {
    color: #f44336;
}

.delete-item-btn:hover {
    background: #ffebee;
}

.add-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.add-btn:hover {
    background: #45a049;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover {
    background: #f5f5f5;
}

/* Forms */
.entry-form, .add-item-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.tag-option:hover {
    background: #e9ecef;
}

.tag-option input[type="checkbox"] {
    width: auto;
}

.grade-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.grade-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.grade-selector label:hover {
    background: #e9ecef;
}

.grade-selector input[type="radio"] {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.save-btn, .delete-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.save-btn {
    background: #4CAF50;
    color: white;
}

.save-btn:hover {
    background: #45a049;
}

.delete-btn {
    background: #f44336;
    color: white;
}

.delete-btn:hover {
    background: #d32f2f;
}

/* Responsive Design */
@media (max-width: 480px) {
    .main {
        padding: 0.5rem;
    }
    
    .header {
        padding: 0.75rem;
    }
    
    .week-title {
        font-size: 1rem;
    }
    
    .timeline-column {
        min-width: 60px;
    }
    
    .lane-label {
        font-size: 0.8rem;
        padding: 0 0.5rem;
    }
    
    .swim-lane {
        min-width: 120px;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .grade-selector {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (min-width: 768px) {
    .days-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1rem;
    }
    
    .swim-lanes-container {
        max-height: 80vh;
        overflow: auto;
    }
    
    .swim-lane {
        min-width: 180px;
    }
    
    .timeline-column {
        min-width: 100px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .day-card, .setting-section, .modal-content, .swim-lanes-container {
        background: #2d2d2d;
    }
    
    .timeline, .lane-label {
        background: #333;
    }
    
    .setting-item, .tag-option, .grade-selector label {
        background: #333;
    }
    
    .form-group input, .form-group select, .form-group textarea {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
}