/* ===== BASE ===== */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

h1, h2, h3, p {
    margin: 0 0 1em 0;
}

a {
    color: #1565c0;
    text-decoration: none;

    &:hover {
        text-decoration: underline;
    }
}

label {
    display: block;
    margin-bottom: 0.5em;
}

input, select, textarea {
    display: block;
    width: 100%;
    padding: 0.5em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    font-family: inherit;
    font-size: 1em;

    &:focus {
        outline: none;
        border-color: #1565c0;
    }
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
    border-color: #c62828;
}

input[aria-invalid="true"] + span[role="alert"],
select[aria-invalid="true"] + span[role="alert"] {
    display: block;
    color: #c62828;
    font-size: 0.875em;
}

input[aria-invalid="false"] + span[role="alert"],
select[aria-invalid="false"] + span[role="alert"] {
    display: none;
}

small {
    color: #c62828;
    font-size: 0.875em;
}

button, input[type="submit"], a[role="button"] {
    display: inline-block;
    padding: 6px 6px;
    background-color: buttonface;
    color: buttontext;
    border: 1px outset buttonborder;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.875em;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);

    &:hover {
        text-decoration: none;
    }
}

table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    margin: 1em 0;

    th, td {
        padding: 0.5em;
        border: 1px solid #ddd;
        text-align: left;
    }

    thead th {
        background-color: #f5f5f5;
        font-weight: bold;
    }
}

/* ===== LAYOUT ===== */

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

header {
    background-color: #e6e6e6;
    padding: 1em;
    border-bottom: 1px solid #ccc;
    text-align: center;

    & .header-top {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        margin-bottom: 0.5em;

        & h1 {
            margin: 0;
        }

        & .logout-btn {
            position: absolute;
            right: 0;
        }
    }

    & nav ul {
        font-weight: 600;
        display: flex;
        justify-content: center;
        gap: 1em;
        list-style: none;
        padding: 0;
        margin: 0;
    }
}

.sub-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.5em;
    border-bottom: 2px solid #ddd;

    & a {
        padding: 0.75em 1.5em;
        text-decoration: none;
        color: #555;
        border-bottom: 2px solid transparent;
        margin-bottom: -2px;
        transition: all 0.2s;

        &:hover {
            color: #1565c0;
            text-decoration: none;
        }

        &.active {
            color: #1565c0;
            border-bottom-color: #1565c0;
            font-weight: 600;
        }
    }
}

.tab-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1em;
}

main {
    flex: 1;
    padding: 2em;
    margin: 0 auto;
}

footer {
    background-color: #f5f5f5;
    text-align: center;
    padding: 1em;
    border-top: 1px solid #ddd;
    color: #555;
    font-size: 0.9em;
}


/* ===== COMPONENTS ===== */

.container {
    max-width: 1200px;
}

.card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    width: 300px;
    padding: 2em;
    text-align: center;

    & h3 {
        margin-bottom: 1em;
        color: #1565c0;
    }

    & p {
        margin-bottom: 1.5em;
        color: #555;
    }

    & a[role="button"] {
        width: 100%;
    }

    &.logout {
        background-color: #fefefe;

        & a {
            border: 2px solid #c62828;
            color: #c62828;
        }
    }
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2em;
    width: 100%;
    max-width: 1000px;
}

#messages {
    max-width: 800px;
    margin: 0 auto 1em auto;

    & .message,
    & .warning,
    & .error {
        position: relative;
        border-radius: 8px;
        padding: 1em 3em 1em 1em;
        margin-bottom: 1em;
        font-weight: 500;
    }

    & .message {
        background-color: #e3f2fd;
        color: #1565c0;
        border: 1px solid #90caf9;
    }

    & .warning {
        background-color: #fff3e0;
        color: #e65100;
        border: 1px solid #ffb74d;
    }

    & .error {
        background-color: #ffebee;
        color: #c62828;
        border: 1px solid #ef5350;
    }

    & .dismiss {
        position: absolute;
        top: 0.5em;
        right: 0.5em;
        background: none;
        border: none;
        font-size: 1.5em;
        line-height: 1;
        cursor: pointer;
        color: inherit;
        opacity: 0.7;
        padding: 0.25em 0.5em;

        &:hover {
            opacity: 1;
        }
    }
}

.tool-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    & input[type="search"],
    & input[type="text"] {
        flex: 1;
    }
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    text-align: center;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5em;

    & h2 {
        margin: 0;
    }

    & .actions {
        display: flex;
        gap: 0.5rem;
    }
}

/* ===== PAGE-SPECIFIC ===== */

.landing-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 50vh;
    padding: 0.5em;

    & .signup {
        margin-top: 1.5em;

        & a {
            text-decoration: none;
        }
    }
}

.splash-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 50vh;
    padding: 2em 1em;

    & h1 {
        margin-bottom: 0.25em;
        color: #1565c0;
    }

    & .intro {
        margin-bottom: 2em;
        color: #555;
        max-width: 600px;
        font-size: 1.1em;
    }
}

.calendar-page {
    max-width: 100%;

    & .calendar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1em;

        & .nav {
            display: flex;
            gap: 1em;
        }
    }

    & .weekdays {
        display: grid;
        grid-template-columns: repeat(7, 120px);
        gap: 1px;
        list-style: none;
        padding: 0;
        margin: 0 0 1px 0;
        background: #ddd;

        & li {
            background: #f5f5f5;
            padding: 0.5em;
            text-align: center;
            font-weight: bold;
        }
    }

    & .day-grid {
        display: grid;
        grid-template-columns: repeat(7, 120px);
        gap: 1px;
        list-style: none;
        padding: 0;
        margin: 0;
        background: #ddd;

        & li {
            background: #fff;
            width: 120px;
            height: 120px;
            padding: 0.5em;
            overflow: hidden;
            display: flex;
            flex-direction: column;

            &.empty {
                background: #fafafa;
            }

            &.today {
                background: #e3f2fd;
                border: 2px solid #1565c0;
            }
        }

        & .day-number {
            font-weight: bold;
            margin-bottom: 0.5em;
            flex-shrink: 0;
        }

        & .tasks {
            list-style: none;
            padding: 0;
            margin: 0;
            overflow-y: auto;
            overflow-x: hidden;
            flex: 1;
            min-height: 0;

            & li {
                padding: 0.25em 0.5em;
                margin-bottom: 0.25em;
                background: #e3f2fd;
                border-radius: 4px;
                font-size: 0.875em;
                line-height: 1.2;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                height: auto;
            }

            & a {
                color: #1565c0;
                text-decoration: none;

                &:hover {
                    text-decoration: underline;
                }
            }
        }
    }
}

