/* Attend Web App - DaisyUI Light & Dark Themes */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body {
    font-family: 'Google Sans', 'Google Sans Text', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.bg-gradient,
.bg-gradient-2 {
    display: none;
}

/* Navbar */
.navbar {
    min-height: 3.5rem;
}

/* Threshold control */
.threshold-control {
    white-space: nowrap;
}

.threshold-control input[type="range"] {
    accent-color: var(--color-primary);
}

/* Table controls */
.table-container {
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

#attendance-table th,
#attendance-table td {
    vertical-align: middle;
}

/* Number input spinners hiding in table */
.attendance-input::-webkit-inner-spin-button,
.attendance-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.attendance-input {
    -moz-appearance: textfield;
}

/* In-chart message */
#in-chart-message .dots {
    display: inline-block;
    animation: blink 1.4s infinite both;
}

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Button loading & disabled states */
.btn.btn-primary:disabled:has(.loading:not(.hidden)),
.btn.btn-primary.btn-loading:disabled,
.btn.btn-primary.btn-loading {
    background-color: var(--color-primary) !important;
    color: var(--color-primary-content) !important;
    opacity: 0.9;
    cursor: wait;
    pointer-events: none;
}

.btn:disabled:not(.btn-loading):not(:has(.loading:not(.hidden))) {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Badge styling to prevent text overflow */
.skippable-cell .badge {
    white-space: nowrap;
    min-width: fit-content;
    padding-left: 0.625rem;
    padding-right: 0.625rem;
    font-size: 0.75rem;
    font-weight: 700;
    height: 1.5rem;
    min-height: 1.5rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Accessibility */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 639px) {
    .navbar {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .threshold-control {
        max-width: 145px;
    }

    /* Prevent horizontal scrolling on table wrapper */
    .table-container > div {
        overflow-x: visible;
    }

    /* Transform table into mobile cards */
    #attendance-table {
        display: block;
        width: 100%;
    }

    #attendance-table thead {
        display: none;
    }

    #attendance-table tbody {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    #attendance-table tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "subject subject"
            "percent buffer"
            "attended total";
        align-items: center;
        gap: 0.625rem 0.5rem;
        padding: 0.875rem 0.75rem;
        border-bottom: 1px solid var(--color-base-200);
        background: transparent;
    }

    #attendance-table tr:last-child {
        border-bottom: none;
    }

    #attendance-table td {
        padding: 0;
        border: none;
    }

    #attendance-table td.subject-cell {
        grid-area: subject;
        font-size: 0.9375rem;
        line-height: 1.35;
        text-align: left;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    #attendance-table td.percentage-cell {
        grid-area: percent;
        text-align: left;
        font-size: 0.9375rem;
        display: flex;
        align-items: center;
    }

    #attendance-table td.percentage-cell::before {
        content: "Attendance: ";
        font-size: 0.75rem;
        font-weight: 500;
        opacity: 0.7;
        margin-right: 0.25rem;
    }

    #attendance-table td.skippable-cell {
        grid-area: buffer;
        text-align: right;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    #attendance-table td.attended-cell {
        grid-area: attended;
    }

    #attendance-table td.total-cell {
        grid-area: total;
    }
}

@media (min-width: 640px) {
    #attendance-table th,
    #attendance-table td {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .skippable-cell {
        white-space: nowrap;
        min-width: 6rem;
    }
}

/* Logout button layout */
#logout-btn {
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

#logout-btn:not([style*="display: none"]) {
    display: inline-flex;
}

#logout-btn svg {
    display: inline-block;
    flex-shrink: 0;
    vertical-align: middle;
}