/* How to use oklch
oklch(밝기, 채도, 색상각) 
L: 밝기 - 높을수록 밝은 색 (0%: 검정 ~ 100%: 흰색)
C: 채도 - 높을수록 선명한 색 (0: 무채색이나 회색 ~ 1)
H: 색상각 - 기본 색깔 조절 (0 ~ 360) ()
*/

@font-face {
    font-family: 'Pretendard';
    font-weight: 400;
    font-style: normal;
    src: url('font\\Pretendard-Regular.woff2')
}

body {
    padding: 0;
    margin: 0;
    height: 100vh;
    background-color: #C6E7FF;
    display: flex;
    justify-content: center;
    align-items: center;
}

button img {
    pointer-events: none;
}

#calendarDiv {
    width: 90vw;
    height: 85vh;
    min-height: 0;
    box-sizing: border-box;
    background-color: white;
    border-radius: 30px;
    border: none;
    text-align: center;
    opacity: 0.8;
    justify-items: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

#calendarGrid {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#calendarMonthDiv {
    display: flex;
    vertical-align: middle;
}

#calendarMonthSpan {
    font-size: 55px;
    font-weight: 700;
    font-family: 'Pretendard';
}

.calendarMonthChangeBtn {
    background-color: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 50px;
    width: 70px;
    height: 70px;
    padding: 5px;
}

.calendarMonthChangeBtn:hover {
    opacity: 0.5;
}

#calendarGridDays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-top: 20px;
    column-gap: 50px;
    flex: 0;
}

#calendarGridDates {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(7,1fr);
    margin-top: 20px;
    column-gap: 50px;
    grid-auto-rows: 1fr;
}

.calendarGridDay {
    font-size: 40px;
    font-family: 'Pretendard';
    font-weight: 700;
}

.calendarGridDate {
    text-align: left;
    display: flex;
    flex-direction: row;
    gap: 20px;
    padding: 20px;
    border: 3px solid white;
    border-radius: 10px;
}

.calendarGridDate:hover {
    opacity: 0.7;
    border: 3px solid #4792E6;
    border-radius: 10px;
}

.calendarGridDateNumber {
    font-size: 30px;
    font-weight: 600;
    font-family: 'Pretendard';
}

.calendarGridDateList {
    font-family: 'Pretendard';
    font-size: 20px;
    font-weight: 570;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: hidden;
}

.calendarGridDateListBlock {
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
    white-space: normal;
    word-break: break-word;
}

.calendarGridDateListBlock:hover {
    opacity: 0.5;
}

.calendarGridDateListBlock[type="schedule"]{
    background-color: #4792E6;
    color: white;
}

#underBar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    padding: 10px;
    background-color: white;
    font-size: 30px;
    font-family: 'Pretendard';
    display: flex;
    flex-direction: row;
    gap: 0;
}

#underBarTime {
    padding: 3px;
    width: 15%;
    text-align: center;
    border-left: 3px solid #4792E6;
    border-right: 3px solid #4792E6;
}

#taskDiv {
    padding: 3px;
    width: 60%;
    display: flex;
    flex-direction: row;
    border-right: 3px solid #4792E6;
    justify-content: center;
    gap: 15px;
}

.taskTopForm {
    display: none; flex-direction: row; gap: 15px;
}

#calendarScheduleAddBtn {
    border: none;
    background-color: #4792E6;
    border-radius: 5px;
    color: white;
    cursor: pointer;
}

#calendarScheduleAddBtn:hover {
    opacity: 0.5;
}

#todoDiv {
    width: 90vw;
    height: 85vh;
    min-height: 0;
    box-sizing: border-box;
    background-color: white;
    border-radius: 30px;
    border: none;
    text-align: center;
    opacity: 0.8;
    justify-items: center;
    padding: 20px;
    display: none;
    gap: 10px;
    grid-template-columns: repeat(2,1fr);
}

#todoTODOdiv {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    width: 100%;
}

#todoTaskDiv {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    width: 100%;
}

.todoBlock {
    background-color: #696FC7;
    color: white;
    font-family: 'Pretendard';
    font-size: 25px;
    text-align: left;
    border: none;
    border-radius: 10px;
    padding: 5px;
    display: grid;
    grid-template-columns: 20px 5fr 2fr 1fr;
    gap: 10px;
}

.todoBlock:hover {
    opacity: 0.7;
}

.todoBlockDeadlineLeft {
    font-style: italic;
    font-weight: bold;
}

.todoBlockDelete {
    border: none;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
    margin-left: 10px;
}

.todoBlockDelete:hover {
    background-color: red;
}

#todoAddoneBtn {
    border: none;
    background-color: #696FC7;
    border-radius: 5px;
    color: white;
    cursor: pointer;
}

#todoAddoneBtn:hover {
    opacity: 0.5;
}

.todoDivSectionTitle {
    font-family: "Pretendard";
    font-weight: 700;
    font-size: 50px;
    cursor: pointer;
}

.todoDivSectionTitle:hover {
    opacity: 0.7;
}

#diaryDiv {
    width: 90vw;
    height: 85vh;
    min-height: 0;
    box-sizing: border-box;
    background-color: white;
    border-radius: 30px;
    border: none;
    text-align: center;
    opacity: 0.8;
    justify-items: center;
    padding: 20px;
    display: none;
    flex-direction: column;
}

#studyDiv {
    width: 90vw;
    height: 85vh;
    min-height: 0;
    box-sizing: border-box;
    background-color: white;
    border-radius: 30px;
    border: none;
    font-family: 'Pretendard';
    opacity: 0.8;
    padding: 20px;
    display: none;
    flex-direction: row;
    gap: 20px;
}

#studyLeft, #studyRight {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Crucial for flex children */
}

#studyLeft {
    flex: 2;
}

#studyRight {
    flex: 1;
}

#studyTimerDiv {
    text-align: center;
    border: 2px solid #C1BAA1;
    border-radius: 10px;
    padding: 10px;
}

#studyTotalTime {
    font-size: 70px;
    font-weight: 700;
}

#studyCurrentSubject {
    font-size: 20px;
    margin-left: 15px;
}

#studyControls {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-height: 60px;
    align-items: center;
}

#studyControls button {
    font-size: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #C1BAA1;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

#studyControls button:hover {
    background-color: #f0f0f0;
}

#studyBottomContent {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    gap: 15px;
    min-height: 0;
}

#studySubjectArea {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-basis: 50%;
    min-width: 0;
}

#studySubjectManagement {
    display: flex;
    gap: 5px;
}

#studySubjectInput {
    flex: 1;
    font-size: 18px;
    padding: 5px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

#studyColorInput {
    height: 100%;
    aspect-ratio: 1/1;
    border: none;
    padding: 0;
    border-radius: 5px;
    cursor: pointer;
}

#studyAddSubjectBtn {
    font-size: 25px;
    border-radius: 5px;
    border: 1px solid #ccc;
    cursor: pointer;
}

#studySubjectList {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    min-height: 150px; /* Give it a minimum height */
}

.studySubjectItem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.studySubjectColor {
    width: 20px;
    height: 20px;
    border-radius: 5px;
}

.studySubjectName {
    flex-grow: 1;
}

.studySubjectItem button {
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 3px;
    background-color: white;
}

#studyTimetableDiv {
    flex-basis: 50%;
    border: 2px solid #C1BAA1;
    border-radius: 10px;
    padding: 10px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.timetable-row {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 5px;
    height: 25%;
}

.timetable-label {
    font-weight: bold;
    text-align: right;
}

.timetable-bar {
    position: relative;
    background-color: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.timetable-block {
    position: absolute;
    height: 100%;
}

#studyStatsControls {
    display: flex;
    justify-content: space-around;
    gap: 5px;
}

#studyStatsControls button {
    flex-grow: 1;
    padding: 10px 5px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
}

#studyStatsControls button.active {
    background-color: #C1BAA1;
    color: white;
}

#studyCharts {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    position: relative;
    min-height: 0;
}

#studyCharts canvas {
    max-height: 50%;
}

#topBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    padding: 10px;
    background-color: white;
    font-size: 30px;
    font-family: 'Pretendard';
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.topBarModeSelectBtn {
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 10px;
}

.topBarModeSelectBtn:hover {
    opacity: 0.5;
}

.todoBlockTitle {
    pointer-events: none;
}

.todoBlockDeadlineLeft {
    pointer-events: none;
}

.todoBlockDeadlineLeft:hover {
    background-color: #4792E6;
}

/* User Auth Styles */
.user-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    background-color: white;
    border-radius: 20px;
    opacity: 0.85;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    font-family: 'Pretendard', sans-serif;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.user-form h3 {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.user-form input {
    font-family: 'Pretendard', sans-serif;
    font-size: 16px;
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
}

.user-form button {
    font-family: 'Pretendard', sans-serif;
    font-size: 18px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background-color: #4792E6;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.user-form button:hover {
    background-color: #3a75b8;
}

.toggle-form-p {
    font-size: 14px;
    margin-top: 10px;
}

.toggle-form-p a {
    color: #4792E6;
    text-decoration: none;
    font-weight: 600;
}

.toggle-form-p a:hover {
    text-decoration: underline;
}

#authStatus {
    margin-bottom: 20px;
}

#authTitle {
    font-size: 24px;
    color: #333;
}

#authMessage {
    font-size: 16px;
    color: #666;
}

#loggedInView {
    font-size: 18px;
}

#loggedInUserName {
    font-weight: bold;
}

#logoutBtn {
    font-family: 'Pretendard', sans-serif;
    font-size: 16px;
    padding: 10px 20px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    background-color: black;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

#logoutBtn:hover {
    background-color: #333; /* Darker gray for hover */
}

#userStatusDiv {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: 'Pretendard';
    font-size: 18px;
    padding-right: 20px;
}

#userNameSpan {
    font-weight: 600;
}

#userStatusDiv a {
    display: flex;
    align-items: center;
}

#userStatusDiv button {
    font-family: 'Pretendard', sans-serif;
    font-size: 14px;
    padding: 5px 10px;
    border: 1px solid #333;
    border-radius: 5px;
    background-color: black;
    color: white;
    cursor: pointer;
    margin: 0; /* Add this line */
}

#userStatusDiv button:hover {
    background-color: #333;
}

#userStatusDiv #loginSignupBtn {
    font-family: 'Pretendard', sans-serif;
    font-size: 14px;
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    background-color: black;
    color: white;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s;
}

#userStatusDiv #loginSignupBtn:hover {
    background-color: #333;
}

/* Media Queries for Responsiveness */

/* Tablet */
@media (max-width: 1024px) {
    #calendarMonthSpan {
        font-size: 40px;
    }
    .calendarGridDay {
        font-size: 24px;
    }
    .calendarGridDateNumber {
        font-size: 22px;
    }
    .calendarGridDateListBlock {
        font-size: 16px;
    }
    #calendarGridDays, #calendarGridDates {
        column-gap: 20px;
    }
    #underBar {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    #underBarTime {
        width: 100%;
        text-align: center;
        border-left: none;
        border-right: none;
        padding: 5px 0;
    }
    #taskDiv {
        width: 100%;
        border-right: none;
        flex-wrap: wrap;
        justify-content: center;
    }
    .taskTopForm {
        flex-wrap: wrap;
        justify-content: center;
    }
    #todoDiv {
        grid-template-columns: 1fr;
    }
    .todoBlock {
        font-size: 20px;
        grid-template-columns: 20px 1fr auto auto; /* Adjust for smaller screens */
        gap: 5px;
    }
    .todoDivSectionTitle {
        font-size: 35px;
    }
    #studyDiv {
        flex-direction: column;
        height: auto;
    }
    #studyLeft, #studyRight {
        width: 100%;
    }
    #studyTotalTime {
        font-size: 50px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    body {
        /* Allow body to scroll on small screens */
        height: auto;
        min-height: 100vh;
    }
    #topBar {
        gap: 5px;
        padding: 5px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .topBarModeSelectBtn img {
        width: 30px;
    }
    #userStatusDiv {
        gap: 10px;
        padding-right: 10px;
        font-size: 14px;
        width: 100%;
        justify-content: flex-end;
    }
    #userStatusDiv button, #userStatusDiv #loginSignupBtn {
        font-size: 12px;
        padding: 5px 8px;
    }
    
    #calendarDiv, #todoDiv, #diaryDiv, #studyDiv {
        width: 95vw;
        height: auto;
        margin-top: 80px; /* Adjust for wrapped topbar */
        margin-bottom: 200px; /* Adjust for underbar */
        padding: 10px;
    }
    #calendarMonthDiv {
        align-items: center;
        justify-content: center;
    }
    #calendarMonthSpan {
        font-size: 28px;
    }
    .calendarMonthChangeBtn {
        width: 50px;
        height: 50px;
    }
    .calendarMonthChangeBtn img {
        width: 40px;
    }
    #calendarGridDays, #calendarGridDates {
        column-gap: 5px;
        margin-top: 10px;
    }
    .calendarGridDay {
        font-size: 14px;
        text-align: center;
    }
    .calendarGridDate {
        padding: 5px;
        gap: 5px;
        flex-direction: column;
        align-items: center;
    }
    .calendarGridDateNumber {
        font-size: 16px;
    }
    .calendarGridDateList {
        font-size: 12px;
        text-align: center;
        gap: 2px;
    }
    .calendarGridDateListBlock {
        font-size: 11px;
        padding: 2px;
    }

    #underBar {
        padding: 5px;
        font-size: 18px;
    }
    #taskDiv {
        gap: 5px;
    }
    .taskTopForm {
        font-size: 14px;
        gap: 5px;
    }
    .taskTopForm label, .taskTopForm input, .taskTopForm select {
        font-size: 14px;
        padding: 3px;
    }
    
    #todoDiv {
        grid-template-columns: 1fr;
        height: auto;
    }
    .todoBlock {
        font-size: 16px;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 5px;
        padding: 10px;
        align-items: center;
        grid-template-areas: 
            "check title button"
            ". deadline deadline";
    }
    .todoBlock > .todoBlockCheckbox { 
        grid-area: check; 
        align-self: center;
    }
    .todoBlock > .todoBlockTitle { 
        grid-area: title; 
        word-break: break-all;
    }
    .todoBlock > .todoBlockDeadlineLeft { 
        grid-area: deadline; 
        font-size: 12px; 
        justify-self: start; 
        padding-left: 0;
        padding-top: 5px;
    }
    .todoBlock > .todoBlockDelete { 
        grid-area: button; 
        margin-left: 0;
    }

    #studyDiv {
        padding: 10px;
    }
    #studyBottomContent {
        flex-direction: column;
    }
    #studyTotalTime {
        font-size: 40px;
    }
    #studyControls button {
        width: 45px;
        height: 45px;
    }
    #studyControls button img {
        width: 25px;
    }
    #studyStatsControls button {
        font-size: 14px;
        padding: 5px;
    }
}
