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

:root {
    --hour-height: 60px;
    --day-height: calc(var(--hour-height) * 24);
    --header-height: 56px;
    --grid-line: #eee;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

/* Tab Styles */
.tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid #ddd;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #efefef;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s;
}

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

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

/* Calendar Grid View */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
}

.week-display {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-align: center;
    flex: 1;
}

.calendar-wrapper {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    height: 650px;
    width: 100%;
}

.calendar-grid {
    display: flex;
    background: white;
    width: 100%;
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

.time-column {
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 60px;
}

.time-label {
    padding: 10px 6px;
    text-align: center;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #ddd;
    height: var(--header-height);
    min-height: var(--header-height);
    flex: 0 0 var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
}

.time-slots {
    display: flex;
    flex-direction: column;
    height: var(--day-height);
    min-height: var(--day-height);
    background: #f9f9f9;
}

.time-slot {
    flex: 0 0 var(--hour-height);
    padding: 0 6px;
    text-align: center;
    font-size: 11px;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    background: #f9f9f9;
    border-right: 2px solid #ddd;
    border-bottom: 1px solid var(--grid-line);
}

.time-slot:last-child {
    border-bottom: none;
}

.week-days-container {
    display: flex;
    flex: 1;
    gap: 0;
    width: 100%;
}

.day-column {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 80px;
}

.day-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 6px;
    text-align: center;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
    border-right: 1px solid #ddd;
    font-size: 12px;
    height: var(--header-height);
    min-height: var(--header-height);
    flex: 0 0 var(--header-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 9;
}

.day-name {
    display: block;
    font-size: 13px;
}

.day-date {
    display: block;
    font-size: 10px;
    margin-top: 1px;
    opacity: 0.9;
}

.day-cycle {
    display: block;
    font-size: 10px;
    margin-top: 2px;
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 4px;
    border-radius: 2px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.day-content {
    flex: 1 0 auto;
    position: relative;
    height: var(--day-height);
    min-height: var(--day-height);
    border-right: 1px solid #ddd;
    background-image: linear-gradient(
        to bottom,
        transparent calc(var(--hour-height) - 1px),
        var(--grid-line) calc(var(--hour-height) - 1px)
    );
    background-size: 100% var(--hour-height);
}

.day-column:last-child .day-header,
.day-column:last-child .day-content {
    border-right: none;
}

.day-content.weekend {
    background-image:
        linear-gradient(#f5f5f5, #f5f5f5),
        linear-gradient(
            to bottom,
            transparent calc(var(--hour-height) - 1px),
            #e4e4e4 calc(var(--hour-height) - 1px)
        );
    background-size: 100% 100%, 100% var(--hour-height);
}

.day-content.vacation {
    background-image:
        linear-gradient(#fff3cd, #fff3cd),
        linear-gradient(
            to bottom,
            transparent calc(var(--hour-height) - 1px),
            #efdba2 calc(var(--hour-height) - 1px)
        );
    background-size: 100% 100%, 100% var(--hour-height);
}

.class-event {
    position: absolute;
    left: 1px;
    right: 1px;
    background: #3366ff;
    color: white;
    padding: 3px 4px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
    line-height: 1.2;
}

.class-event:hover {
    box-shadow: 0 2px 8px rgba(51, 102, 255, 0.3);
    transform: scale(1.02);
}

.class-event.homework {
    background: #ff6633;
}

.class-event.task {
    background: #33cc33;
}

.class-event.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.empty-day {
    color: #ccc;
    text-align: center;
    padding: 20px;
    font-size: 12px;
}

.event-item {
    background: #f9f9f9;
    border-left: 4px solid #667eea;
    padding: 12px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 10px;
}

.event-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.event-item.class {
    border-left-color: #3366ff;
}

.event-item.homework {
    border-left-color: #ff6633;
}

.event-item.task {
    border-left-color: #33cc33;
}

.event-item.completed {
    opacity: 0.6;
    background: #f0f0f0;
}

.event-item {
    background: #f9f9f9;
    border-left: 4px solid #667eea;
    padding: 12px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.event-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.event-item.class {
    border-left-color: #3366ff;
}

.event-item.homework {
    border-left-color: #ff6633;
}

.event-item.task {
    border-left-color: #33cc33;
}

.event-item.completed {
    opacity: 0.6;
    background: #f0f0f0;
}

.event-item.auto {
    background: #e3f2fd;
    border-left-color: #2196f3;
    opacity: 0.9;
}

.event-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.event-content {
    flex: 1;
}

.event-time {
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
}

.event-title {
    color: #333;
    font-size: 16px;
    font-weight: 600;
    margin-top: 2px;
}

.event-title.completed {
    text-decoration: line-through;
    color: #999;
}

.event-description {
    color: #666;
    font-size: 13px;
    margin-top: 3px;
}

.event-delete {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.event-delete:hover {
    background: #ff5252;
}

.buttons-section {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.add-btn {
    padding: 12px 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
    font-size: 14px;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.class-btn {
    background: #3366ff;
}

.homework-btn {
    background: #ff6633;
}

.task-btn {
    background: #33cc33;
}

/* Schedule Setup Tab */
.schedule-container {
    max-height: 75vh;
    overflow-y: auto;
}

.schedule-settings,
.schedule-classes,
.schedule-vacations {
    margin-bottom: 30px;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
}

.schedule-settings h3,
.schedule-classes h3,
.schedule-vacations h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 16px;
}

.classes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.class-day-btn {
    padding: 15px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    text-align: center;
}

.class-day-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.class-day-btn.has-class {
    border-color: #667eea;
    background: #e3f2fd;
    font-weight: 600;
}

.class-day-label {
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
}

.class-day-name {
    color: #666;
    font-size: 12px;
    margin-top: 3px;
}

.class-day-time {
    color: #999;
    font-size: 11px;
    margin-top: 3px;
}

.vacation-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.vacation-form .form-group {
    margin-bottom: 0;
}

.vacations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vacation-item {
    background: white;
    border-left: 4px solid #ff9800;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.vacation-delete-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.vacation-delete-btn:hover {
    background: #ff5252;
}

/* Letter Days Tab */
.letter-days-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.letter-day-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    padding: 12px;
}

.letter-day-card h3 {
    margin-bottom: 10px;
    color: #333;
}

.letter-class-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.letter-class-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
}

.letter-class-row input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
}

.letter-day-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

/* Tasks Container */
.tasks-container {
    max-height: 75vh;
    overflow-y: auto;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

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

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-save,
.btn-cancel {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save {
    background: #667eea;
    color: white;
}

.btn-save:hover {
    background: #764ba2;
}

.btn-cancel {
    background: #ccc;
    color: #333;
}

.btn-cancel:hover {
    background: #bbb;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 30px 20px;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        border-radius: 0;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        font-size: 12px;
        padding: 10px;
    }

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

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

    .letter-days-grid {
        grid-template-columns: 1fr;
    }

    .letter-class-row {
        grid-template-columns: 1fr;
    }

    .add-btn {
        padding: 15px;
    }

    header h1 {
        font-size: 22px;
    }
}
