/* Shared application shell, preferences and accessibility refinements. */

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--blue) 38%, transparent);
    outline-offset: 3px;
}

:where(.action-button, .primary-button, .secondary-button, .danger-button, .danger-link) {
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease,
        background-color 0.15s ease;
}

:where(.action-button, .primary-button, .secondary-button, .danger-button, .danger-link):hover {
    transform: translateY(-1px);
}

button:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.58;
}

body.dialog-open {
    overflow: hidden;
}

.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.mobile-nav-toggle svg {
    width: 21px;
    height: 21px;
}

.mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    border: 0;
    background: rgba(7, 12, 24, 0.5);
    cursor: pointer;
}

.topbar-calendar-icon {
    font-size: 20px;
}

.topbar-search-icon {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
}

.notification-wrapper,
.profile-menu-container {
    position: relative;
}

.notification {
    cursor: pointer;
}

.notification-dropdown,
.profile-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 30;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 18px 46px rgba(20, 31, 54, 0.18);
    text-align: left;
}

.notification-dropdown {
    width: min(340px, calc(100vw - 28px));
    padding: 12px;
}

.notification-title {
    margin: 0;
    padding: 3px 4px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.notification-list {
    max-height: min(420px, 65vh);
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--surface-muted);
    color: var(--text);
    font-size: 13px;
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-item.unread .notification-link {
    font-weight: 800;
}

.notification-content {
    min-width: 0;
    flex: 1;
}

.notification-link {
    display: block;
    overflow-wrap: anywhere;
}

.notification-time {
    color: var(--muted);
    font-weight: 500;
}

.notification-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--red);
    cursor: pointer;
}

.notification-delete:hover {
    background: var(--red-soft);
}

.notification-empty {
    margin: 0;
    padding: 12px 4px 4px;
    color: var(--muted);
    font-size: 13px;
}

.profile-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.profile-menu-trigger:hover {
    border-color: var(--blue-soft);
}

.profile-menu-avatar,
.profile-menu-image {
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 50%;
    object-fit: cover;
}

.profile-menu-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
}

.profile-menu-dropdown {
    width: 250px;
    padding: 7px 0;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 9px 15px;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    text-align: left;
}

button.profile-menu-item,
a.profile-menu-item {
    cursor: pointer;
}

.profile-menu-item + .profile-menu-item,
.profile-menu-item + .profile-preference-row,
.profile-preference-row + .profile-preference-row,
.profile-menu-logout {
    border-top: 1px solid var(--border);
}

.profile-preference-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    padding: 8px 15px;
    color: var(--text);
    font-size: 14px;
}

.preference-button,
.language-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 30px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-weight: 750;
}

.language-form,
.language-buttons {
    display: flex;
    gap: 4px;
    margin: 0;
}

.language-button[aria-pressed="true"] {
    border-color: var(--blue-solid);
    background: var(--blue-solid);
    color: #fff;
}

.profile-menu-logout {
    margin: 0;
    padding-top: 4px;
}

.profile-menu-logout .profile-menu-item {
    color: var(--red);
}

.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(4px);
}

.dialog-card {
    position: relative;
    width: min(500px, 100%);
    max-height: calc(100vh - 40px);
    padding: 28px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(7, 12, 24, 0.3);
    animation: popIn 0.2s ease-out;
}

.dialog-card.compact {
    width: min(520px, calc(100% - 32px));
    text-align: center;
}

.calendar-dialog-title {
    margin: 0 0 24px;
}

.calendar-choice-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.calendar-choice.task { background: var(--green-solid); border-color: var(--green-solid); }
.calendar-choice.lecture,
.calendar-choice.plan { background: var(--purple-solid); border-color: var(--purple-solid); }
.calendar-choice.deadline { background: var(--red-solid); border-color: var(--red-solid); }

.calendar-add-action {
    margin-right: 8px;
}

.calendar-add-action.task { background: var(--green-solid); border-color: var(--green-solid); }
.calendar-add-action.lecture { background: var(--purple-solid); border-color: var(--purple-solid); }

.calendar-action-icon {
    margin-right: 4px;
    vertical-align: middle;
}

.dialog-card.profile-dialog-card {
    width: min(460px, 100%);
}

.dialog-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    cursor: pointer;
    font-size: 19px;
}

.dialog-heading {
    margin: 0 42px 16px 0;
    font-size: 22px;
}

.about-intro,
.about-features {
    color: var(--text);
    font-size: 14px;
    line-height: 1.65;
}

.about-heading {
    margin: 18px 0 8px;
    font-size: 16px;
}

.about-features {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 20px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.profile-form,
.profile-picture-section,
.cropper-wrap,
.profile-field {
    display: flex;
    flex-direction: column;
}

.profile-form {
    gap: 15px;
}

.profile-picture-section {
    align-items: center;
    gap: 10px;
}

.profile-picture-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    overflow: hidden;
    border: 2px solid var(--blue);
    border-radius: 50%;
    background: var(--surface-soft);
}

.profile-picture-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-picture-placeholder {
    display: flex;
    color: var(--blue);
    font-size: 32px;
    font-weight: 800;
}

.profile-upload-button {
    cursor: pointer;
}

.cropper-wrap {
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 9px;
    background: var(--surface-muted);
}

.cropper-frame {
    max-width: 100%;
    max-height: 220px;
    overflow: hidden;
    border-radius: 5px;
}

.cropper-frame img {
    display: block;
    max-width: 100%;
}

.cropper-hint {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.profile-field {
    gap: 5px;
}

.profile-field label {
    font-size: 13px;
    font-weight: 750;
}

.profile-field input {
    width: 100%;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.profile-tutorial-help {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
}

.profile-tutorial-help strong {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.profile-tutorial-help p {
    margin: 0 0 10px;
}

@media (max-width: 980px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(320px, calc(100vw - 48px));
        min-height: 100vh;
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
    }

    .app-shell.nav-open .sidebar {
        transform: translateX(0);
    }

    .side-nav {
        grid-template-columns: 1fr;
    }

    .mobile-nav-toggle {
        display: inline-flex;
    }

    .topbar {
        display: flex;
        padding: 14px 20px;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }
}

@media (max-width: 640px) {
    h1 {
        font-size: clamp(24px, 8vw, 30px);
    }

    .topbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 14px;
    }

    .search-box {
        order: 3;
        max-width: none;
        flex-basis: 100%;
    }

    .top-actions {
        gap: 8px;
    }

    .page {
        padding: 20px 14px;
    }

    .page-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions > :where(a, button) {
        flex: 1 1 auto;
    }

    .notification-dropdown,
    .profile-menu-dropdown {
        position: fixed;
        top: 70px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .dialog-card {
        padding: 22px 18px;
    }

    .dialog-actions,
    .button-row,
    .form-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .dialog-actions > *,
    .button-row > *,
    .form-actions > * {
        width: 100%;
    }

    .site-footer,
    .footer-left,
    .footer-right {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
