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

html,
body {
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* 1. Defind color object */
:root {
    /* Light Mode */
    --bg-color: #e0e0d6;
    --sidebar-bg: #d4d4c7;
    --card-bg: #f0f0e8;
    --text-color: #211b34;
    --accent-color: #211b34;
    --accent-hover: #2b221c;
    --accent-text: #ffffff;
    --border-color: #1a1a1a;
    --glass-bg: rgba(212, 212, 199, 0.7);
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-color: #0f1427;
    --sidebar-bg: #18203e;
    --card-bg: #18203e;
    --text-color: #e0e0d6;
    --accent-color: #e0e0d6;
    --accent-hover: #ffffff;
    --accent-text: #1a1a1a;
    --border-color: #040710;
    --glass-bg: rgba(14, 22, 45, 0.8);
}

/* 2. For global */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: none;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.4s ease, color 0.4s ease;
    width: 100%;
    height: 100vh;
    background-color: var(--bg-color);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    box-sizing: border-box;
}

h1,
h3 {
    color: var(--text-color);
}

p {
    color: var(--secondary-text);
}

/* For text places */

textarea,
input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--container-bg);
    color: var(--text-color);
    font-family: inherit;
    box-sizing: border-box;
    min-height: 60px;
}

textarea {
    /*specific for textarea to not conflict with script in index.html*/
    resize: none;
    overflow-y: hidden;
    min-height: 60px;
}

/* 3. For specifics */

.user-info {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    overflow: hidden;
}

/* main layout */
.app-container {
    display: flex !important;
    width: 100vw;
    height: 100dvh;
    align-items: flex-start;
    overflow: hidden;
}

/* Sidebar left - main navigate */
.sidebar {
    width: 290px;
    height: 100dvh;
    max-height: 100dvh;
    position: sticky;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    background-color: var(--glass-bg) !important;
    border-right: 3px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: width 0.3s ease-in-out;
    overflow: hidden;

    z-index: 1000;
    padding: 0;

}

.sidebar .btn-text {
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .btn-text {
    opacity: 0;
    pointer-events: none;
}

.sidebar.collapsed {
    width: 80px !important;
}

.sidebar.collapsed .sidebar-top-group {
    padding: 30px 0;
    align-items: center;
}


.sidebar.collapsed .sidebar-footer {
    justify-content: center !important;
    padding: 20px 0 !important;
}


.sidebar.collapsed .btn-text,
.sidebar.collapsed .user-info h2 {
    display: none !important;
}

.sidebar.collapsed .start-btn {
    width: 50px !important;
    height: 50px !important;
    padding: 0 !important;
    justify-content: center !important;
    margin: 0 auto 15px auto !important;
    box-shadow: 4px 4px 0px var(--border-color);
}

.sidebar.collapsed .toggle-btn {
    width: auto;
    padding: 0;
}

/* three-line navigate */
.toggle-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 20px;
    width: 100%;
    transition: all 0.3s ease;
}

/* more modify for sidebar */
.sidebar-top-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    gap: 15px;
    align-items: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

/* right side */
.main-content {
    flex: 1;
    height: 100dvh;
    overflow-y: auto;
    padding: 30px;
    transition: all 0.3s ease-in-out;
}

/* 2. Grid each note */
.note-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 25px;
}

.note-card {
    background-color: var(--card-bg);
    border: 3px solid var(--border-color);
    padding: 20px;
    min-height: 155px;
    height: auto;

    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 5px 5px 0px var(--border-color);
}

.note-preview {
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    margin-bottom: 15px;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card:hover {
    transform: translateY(-5px);
    box-shadow: 10px 10px 0px var(--border-color);
}

.note-date {
    font-size: 12px;
    align-self: flex-end;
    font-weight: bold;
}

/* 3. CSS Modal Popup */
.modal {
    display: none;

    position: fixed;
    z-index: 9999 !important;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);

    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-color);
    margin: 5% auto;
    padding: 40px;
    border: 4px solid var(--border-color);
    width: 60%;
    max-width: 800px;
    position: relative;
    box-shadow: 20px 20px 0px var(--border-color);
    z-index: 10000 !important;
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 40px;
    cursor: pointer;
}

#modal-textarea {
    white-space: pre-wrap;
    width: 100%;
    height: 300px;
    background: transparent;
    border: 2px solid var(--text-color);
    padding: 15px;
    font-family: inherit;
    font-size: 18px;
    resize: none;
    margin: 20px 0;
}

/* ------------------New for welcome page-------------------- */
.split-screen {
    display: flex;
    height: 100vh;
    width: 100vw;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

.left-section {
    flex: 1.5;
    padding: 0 10%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.right-section {
    flex: 1;
    position: relative;
}

.right-section img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-badge {
    position: absolute;
    top: 80px;
    left: 85%;
    background-color: var(--card-bg);
    border: 3px solid var(--border-color);
    padding: 15px 30px;
    transform: rotate(-10deg);
    display: flex;
    align-items: center;
    gap: 30px;
    z-index: 10;
    box-shadow: 8px 8px 0px var(--border-color);
    color: var(--text-color);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.brand-badge:hover {
    transform: translateX(-40%) rotate(-3deg) scale(1.05);
    box-shadow: 15px 15px 0px #e03070d1;
    cursor: default;
}

.emoji {
    font-size: 60px;
}

.brand-text {
    font-size: 60px;
    font-weight: bold;
    color: var(--text-color);
}

.project-tag {
    font-size: 14px;
    letter-spacing: 1px;
    margin-bottom: 40px;
}

.welcome-main h2 {
    font-family: 'Courier New', Courier, monospace;
    font-size: 28px;
}

.my-info h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 55px;
    opacity: 0.8;
    position: absolute;
    bottom: 50px;
    left: 14.7%;

}

.insta-link {
    text-decoration: none;
    color: inherit;
}

.insta-info {
    display: inline-block;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 16px;
    padding: 5px 10px;
    background-color: var(--accent-color);
    color: var(--accent-text) !important;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
    position: absolute;
    bottom: 50px;
    left: 14.7%;

}

.insta-info:hover {
    transform: translate(-3px, -3px);
    box-shadow: 4px 4px 0px var(--border-color);
    cursor: pointer;
}

/* INPUT & BUTTON */
.name-input {
    background: transparent !important;
    border: 3px solid var(--text-color) !important;
    border-radius: 0 !important;
    font-size: clamp(24px, 5vw, 48px) !important;
    padding: 25px !important;
    font-family: 'Courier New', Courier, monospace;
    width: 100% !important;
    margin-top: 20px;
    color: var(--text-color) !important;
}

.start-btn {
    margin: 0px auto;
    background-color: var(--accent-color) !important;
    color: var(--accent-text) !important;
    font-weight: bold;
    padding: 15px 40px !important;
    border-radius: 0px !important;
    border: 3px solid var(--border-color) !important;
    font-size: 24px !important;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    box-shadow: 8px 8px 0px var(--border-color);
}

.start-btn i {
    min-width: 20px;
    text-align: center;
}

.btn-text {
    flex: 1;
    text-align: left;
    opacity: 1;
    transition: opacity 0.3s ease;
    width: 90%;
}

.start-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 10px 10px 0px var(--border-color);
    background-color: var(--accent-hover) !important;
}

.start-btn:active {
    transform: translate(6px, 6px);
    box-shadow: none;
}

.sidebar-nav .start-btn {
    display: flex !important;
    align-items: center;
    gap: 15px;
    width: 100% !important;
    height: 50px;
    /* height of navigate button */
    margin-bottom: 15px;
    padding: 15px !important;
    background-color: var(--sidebar-bg) !important;
    color: var(--text-color) !important;
    border: 3px solid var(--border-color) !important;
    box-shadow: 6px 6px 0px var(--border-color);
    cursor: pointer;
    font-size: 1.1rem !important;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.2s ease;
}

.sidebar-nav .start-btn:hover {
    background-color: var(--card-bg) !important;
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0px var(--border-color);
}

.sidebar-nav .start-btn:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

.sidebar-top-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 30px 20px;
    overflow-y: auto;
}

.sidebar-footer {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Button in modal action */
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    width: 100%;
    flex-wrap: wrap;
}

.modal-actions .start-btn {
    min-width: 100px;
    padding: 10px 20px !important;
    font-size: 16px !important;
    width: auto !important;
    box-shadow: 4px 4px 0px var(--border-color);
}


.modal-actions .delete-btn {
    background-color: #ff4d4d !important;
    color: white !important;
}

.modal-actions .delete-btn:hover {
    background-color: #ff0000 !important;
}

/* 📱 Responsive for Phone and Tablet */
@media (max-width: 768px) {

    /* modify for welcome page */
    .split-screen {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .left-section {
        padding: 60px 20px !important;
        justify-content: flex-start;
        min-height: 100vh;
        align-items: center;
        justify-content: center;
        text-align: center;
        min-height: 100vh;
    }

    form {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .brand-badge {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        margin: 20px auto 40px !important;
        width: fit-content;
        box-shadow: 6px 6px 0px var(--border-color) !important;
    }

    .brand-text,
    .emoji {
        font-size: 30px !important;
    }

    .my-info {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        margin-top: 60px !important;
        text-align: center;
        width: 100% !important;
        border-top: 2px dashed var(--border-color);
        padding-top: 20px;
    }

    .my-info h3,
    .insta-info {
        position: static !important;
        display: block;
        margin: 10px auto !important;
        width: fit-content;
    }

    /* rolate main layout */
    @media (max-width: 768px) {

        .modal-content {
            width: 90% !important;
            /* Mở rộng modal ra cho dễ nhìn trên điện thoại */
            padding: 20px !important;
            margin: 20% auto !important;
            /* Đẩy modal xuống giữa màn hình */
        }

        .modal-actions {
            justify-content: center !important;
            /* Căn giữa nút trên Mobile */
            gap: 10px !important;
        }

        .modal-actions .start-btn {
            flex: 1;

            font-size: 14px !important;
            padding: 12px 10px !important;
            white-space: nowrap;

        }


        .app-container {
            display: block !important;
            height: auto !important;
            min-height: 100dvh;
        }

        html,
        body {
            overflow-y: auto !important;
            height: auto !important;
            position: relative;
        }


        .sidebar {
            width: 100% !important;
            max-height: 60px;
            /* for the collapsed sidebar*/

            position: fixed;
            top: 0;
            left: 0;
            display: flex !important;
            flex-direction: column;
            padding: 0 !important;
            border-right: none;
            border-bottom: 3px solid var(--border-color);
            z-index: 2000;
            overflow: hidden;


            background-color: var(--glass-bg) !important;
            backdrop-filter: blur(15px) saturate(180%);
            -webkit-backdrop-filter: blur(15px) saturate(180%);
            transition: max-height 0.3s ease-in-out, background-color 0.3s ease;
            will-change: max-height;
        }


        .sidebar.mobile-open {
            max-height: 564px !important;
            overflow-y: auto;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        }

        .sidebar-footer {
            width: 100%;
            height: 60px;
            /* for the three-line button - same px with collapsed sidebar*/
            display: flex !important;
            align-items: center;
            justify-content: flex-start !important;
            padding: 0 10px !important;
            order: 1;

        }

        .toggle-btn {
            width: 50px;
            height: 60px;
            /* for the three-line button - same px with collapsed sidebar*/
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            background: none;
            border: none;
            color: var(--text-color);
            cursor: pointer;
        }


        .sidebar-top-group {
            width: 100%;
            display: none !important;
            flex-direction: column;
            padding: 20px !important;
            gap: 15px;
            order: 2;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .sidebar.mobile-open .sidebar-top-group {
            display: flex !important;
            opacity: 1;
        }


        .sidebar.mobile-open .start-btn {
            width: 100% !important;
            margin: 5px 0 !important;
            justify-content: flex-start !important;
            padding: 15px 20px !important;
        }


        .main-content {
            margin-top: 80px !important;
            padding: 20px !important;
            height: auto !important;
            overflow-y: visible !important;
        }


        .sidebar:not(.mobile-open) .user-info,
        .sidebar:not(.mobile-open) .btn-text {
            display: none !important;
        }



    }

    /* modify note */
    .note-grid {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
        gap: 12px !important;
        padding: 10px 0;
    }

    .note-card {
        padding: 12px !important;
        min-height: 120px !important;
    }

    .note-card h3 {
        font-size: 1rem !important;
    }

    .note-card p {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* modify welcome page */
    .right-section {
        display: none;
    }

    .left-section {
        padding: 40px 20px;
        text-align: center;
    }

    /* modify photo and brand-badge */
    .brand-badge {
        position: static;
        transform: none;
        margin: 0 auto 30px;
        justify-content: center;
    }

    .brand-text,
    .emoji {
        font-size: 30px;
    }

    .name-input {
        font-size: 1.5rem !important;
        width: 80% !important;
        margin-bottom: 30px !important;
        text-align: center;
    }

    .start-btn {
        margin: 0 auto !important;
        width: fit-content !important;
        padding: 15px 40px !important;
    }
}

/* for flash notification */
.flash-container {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flash-message {
    background: #b3e5fc;
    color: #01579b;
    padding: 12px 25px;
    border-radius: 50px;
    border: 3px solid #01579b;
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* other */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
    pointer-events: none;
}