/* ==========================================================================
   Chronos — UX layer (loaded last, on top of themes.css / sidebar.css)
   Additive polish only: it never overrides the colours the user picks in
   the customization modal (.custom-level-*, .menu_btn_*, .thead_*, wallpaper).
   ========================================================================== */

:root {
    --ux-radius: 10px;
    --ux-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --ux-surface: rgba(29, 30, 32, 0.92);
    --ux-surface-border: rgba(255, 255, 255, 0.10);
    --ux-hover: rgba(255, 255, 255, 0.055);
    --ux-focus: #6aa3ff;
    --ux-success: #34d399;
    --ux-error: #f87171;
    --ux-info: #60a5fa;
}

/* ---------- Base ------------------------------------------------------- */

html { scroll-behavior: smooth; }

::selection { background: rgba(106, 163, 255, 0.35); }

/* Discreet scrollbars that match the dark UI */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.32); background-clip: padding-box; border: 2px solid transparent; }
.sidebar { scrollbar-width: none; }

/* Keyboard focus is always visible, mouse focus stays quiet */
:focus-visible {
    outline: 2px solid var(--ux-focus);
    outline-offset: 2px;
    border-radius: 6px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-medium);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom-width: 2px;
    border-radius: 6px;
}

/* ---------- Page loading + transitions --------------------------------- */

#ux-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 100000;
    pointer-events: none;
    background: linear-gradient(90deg, var(--accent-primary), #8b5cf6);
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.6);
    transition: width 0.25s var(--ux-ease), opacity 0.3s ease;
}

.page-enter { animation: uxPageIn 0.28s var(--ux-ease); }
@keyframes uxPageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Sidebar ---------------------------------------------------- */

.sidebar-brand { cursor: pointer; border-radius: var(--ux-radius); padding: 2px 4px; transition: background-color 0.15s ease; }
.sidebar-brand:hover { background-color: var(--ux-hover); }

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    color: var(--text-medium);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color-subtle);
    border-radius: var(--ux-radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.sidebar-search:hover { color: var(--text-light); border-color: var(--border-color-medium); background: rgba(0, 0, 0, 0.35); }
.sidebar-search span:not(.kbd-group) { flex: 1; text-align: left; }
.sidebar-search .kbd-group { display: inline-flex; gap: 3px; }
.sidebar-search kbd { height: 18px; min-width: 18px; font-size: 10px; padding: 0 4px; }

/* Navigation: always visible (it used to appear only on hover) */
.sidebar #main-nav-container ul > li,
.sidebar #main-nav-container:hover ul > li,
.sidebar #main-nav-container ul > li.active-link {
    max-height: none;
    overflow: visible;
}
.sidebar .nav-link { cursor: pointer; user-select: none; }
.sidebar .nav-link:hover i { color: var(--text-light); }
.sidebar .nav-link.active { font-weight: 600; }

/* Urgent tasks: same glass language as the rest of the sidebar */
.sidebar .urgent-tasks-section {
    background-color: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border-color-subtle);
    border-radius: 12px;
    padding-bottom: 6px !important;
}
.sidebar .urgent-tasks-section h3 { font-size: 0.95rem; margin: 10px 12px 8px; }
.sidebar .urgent-tasks-section ul { padding: 0 8px 4px; }
.urgent-notification {
    width: 100%;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.04);
}
.urgent-notification > span { display: block; }
.urgent-notification .text-red-200 { color: #fecaca; opacity: 0.85; }
.urgent-empty {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 8px;
    font-size: 12.5px;
    color: var(--text-medium);
}
.urgent-empty i { color: var(--ux-success); font-size: 15px; }

/* Calendar */
#calendar-container h4 { cursor: pointer; border-radius: 6px; padding: 2px 6px; transition: background-color 0.15s ease; }
#calendar-container h4:hover { background-color: var(--ux-hover); }
.calendar-section .grid > div.cursor-pointer { transition: background-color 0.15s ease; }
.calendar-chip-day { box-shadow: 0 0 0 2px var(--accent-primary); border-color: transparent; background-color: rgba(0, 123, 255, 0.45); }

/* ---------- Toasts ------------------------------------------------------ */

#notifications-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}
#notifications-container > * { margin: 0 !important; }
.notification {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 260px;
    max-width: 100%;
    padding: 12px 10px 12px 14px;
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.4;
    background: var(--ux-surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--ux-surface-border);
    border-left-width: 3px;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transform: translateX(28px);
    transition: opacity 0.28s ease, transform 0.28s var(--ux-ease);
}
.notification.show { transform: none; }
.notification.success { background: var(--ux-surface); border-color: var(--ux-surface-border); border-left-color: var(--ux-success); }
.notification.error   { background: var(--ux-surface); border-color: var(--ux-surface-border); border-left-color: var(--ux-error); }
.notification.info    { background: var(--ux-surface); border-color: var(--ux-surface-border); border-left-color: var(--ux-info); }
.notif-icon { font-size: 18px; line-height: 1.25; flex-shrink: 0; }
.notification.success .notif-icon { color: var(--ux-success); }
.notification.error .notif-icon   { color: var(--ux-error); }
.notification.info .notif-icon    { color: var(--ux-info); }
.notif-msg { flex: 1; word-break: break-word; }
.notif-close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    font-size: 18px;
    line-height: 1;
    color: var(--text-dark);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.notif-close:hover { color: var(--text-light); background: var(--ux-hover); }

/* ---------- Modals ------------------------------------------------------ */

#modal-backdrop {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
#modal-backdrop:not(.hidden) { animation: uxFade 0.18s ease; }
#task-modal:not(.hidden) #modal-scroll-container { animation: uxModalIn 0.22s var(--ux-ease); }
@keyframes uxFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes uxModalIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
/* Gentle "shake" when a click outside is ignored because the form has unsaved input */
#modal-scroll-container.modal-nudge { animation: uxNudge 0.3s ease; }
@keyframes uxNudge {
    0%, 100% { transform: none; }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ---------- Home: toolbar ---------------------------------------------- */

.toolbar-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    width: 190px;
    padding: 0 10px;
    border-radius: 9999px;
    background-color: var(--background-medium);
    border: 1px solid var(--border-color-subtle);
    color: var(--text-medium);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.toolbar-search:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}
.toolbar-search > i { font-size: 15px; flex-shrink: 0; }
.toolbar-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    font-size: 13px;
    color: inherit;
    background: transparent !important;
    border: none;
    outline: none;
}
.toolbar-search input:focus-visible { outline: none; }
.toolbar-search input::placeholder { color: var(--text-dark); }
.toolbar-search:focus-within .toolbar-search-hint { display: none; }
.toolbar-search #task-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    cursor: pointer;
}
.toolbar-search #task-search-clear[hidden] { display: none; }
.toolbar-search #task-search-clear:hover { background: rgba(255, 255, 255, 0.2); }
.toolbar-search-hint { height: 18px; min-width: 18px; font-size: 10px; }
.toolbar-search:has(#task-search-clear:not([hidden])) .toolbar-search-hint { display: none; }

.filter-button[hidden] { display: none; }
.filter-button.filter-reset {
    color: #fca5a5;
    border-color: rgba(220, 53, 69, 0.4);
    background-color: rgba(220, 53, 69, 0.1);
}
.filter-button.filter-reset:hover { background-color: rgba(220, 53, 69, 0.2); border-color: rgba(220, 53, 69, 0.6); }

.toolbar-btn { cursor: pointer; }
.toolbar-btn i { font-size: 17px; pointer-events: none; }
.toolbar-btn-group { display: inline-flex; gap: 0; }
.toolbar-btn-group .toolbar-btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.toolbar-btn-group .toolbar-btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; }
.toolbar-btn-label { font-size: 13px; font-weight: 600; margin-left: 6px; }
.toolbar-btn-primary { padding: 0 12px 0 9px; }

/* The hover menus of the toolbar must not close while the pointer crosses the gap */
.toolbar-btn + .toolbar-menu::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -6px;
    height: 6px;
}
.rounded_list.toolbar-menu { overflow: visible; }
.rounded_list.toolbar-menu { margin-top: 4px; }
.rounded_list.toolbar-menu a { cursor: pointer; }

/* Filter dropdowns open with a soft motion */
div[id^="filter-"][id$="-dropdown"]:not(.hidden),
#future-horizon-dropdown:not(.hidden) { animation: uxPop 0.14s var(--ux-ease); transform-origin: top left; }
@keyframes uxPop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Home: tables ----------------------------------------------- */

/* Row hover: an inset veil, so the user's level colours stay untouched */
.task-table tbody tr:not(.task-drop-hover):hover > td { box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, 0.04); }
.task-table tbody tr[data-task-id], .task-table tbody tr[data-project-id] { cursor: default; }
.task-table .project-line, .task-table .task-toggle-area { cursor: pointer; }

/* "Éditer": quiet until the row is hovered */
.task-table .edit-link {
    display: inline-flex;
    align-items: center;
    padding: 2px 11px;
    font-size: 0.8rem;
    border: 1px solid transparent;
    border-radius: 9999px;
    cursor: pointer;
    opacity: 0.6;
    text-decoration: none !important;
    transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.task-table tr:hover .edit-link, .task-table .edit-link:focus-visible {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.16);
}

/* Chevron rotates smoothly */
.task-table .toggle-icon { transition: transform 0.18s var(--ux-ease); }

/* While filtering by text, matching rows inside collapsed parents are shown */
#tasks-container.searching tr.hidden:not(.filter-hidden) { display: flex; }

/* Empty state (filters match nothing) */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 28px auto;
    padding: 34px 24px;
    max-width: 440px;
    text-align: center;
    color: var(--text-medium);
    background: rgba(29, 30, 32, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px dashed rgba(255, 255, 255, 0.16);
    border-radius: 16px;
}
.empty-state[hidden] { display: none; }
.empty-state > i { font-size: 34px; color: var(--text-dark); }
.empty-state-title { font-size: 16px; font-weight: 700; color: var(--text-light); }
.empty-state-text { font-size: 13.5px; margin-bottom: 8px; }

/* ---------- Dropdowns (status / priority cells) ------------------------ */

.task-table .toggle-dropdown { cursor: pointer; transition: filter 0.15s ease, transform 0.1s ease; }
.task-table .toggle-dropdown:hover { filter: brightness(1.08); }
.task-table .toggle-dropdown:active { transform: scale(0.97); }
.dropdown-menu { animation: uxPop 0.12s var(--ux-ease); }

/* Spotlight : voir spotlight.css */

/* ---------- Other pages ------------------------------------------------- */

/* Dashboard title */
.dashboard-view > h1 {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0.35rem 1.25rem;
    font-size: 1.6rem !important;
    margin-bottom: 1.5rem !important;
    background: rgba(40, 40, 40, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
}
.dashboard-view > h1::before { content: "\1F4CA"; font-size: 1.25rem; }
.dash-card a[data-days], .dash-card nav a { cursor: pointer; transition: color 0.15s ease, border-color 0.15s ease; }

/* Daily: friendlier empty editor */
#daily-textarea::placeholder { color: var(--text-dark); font-style: italic; }
.daily-date-label:empty { display: none; }

/* Meetings: a card is clearly a thing you can act on */
.meeting-item-title { overflow-wrap: anywhere; }
.meeting-empty {
    padding: 2.5rem 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 14px;
}
.table-action-btn { cursor: pointer; }

/* Buttons share one pressed state */
.save-button, .close-button, .delete-button, .exec-button, .spe-button, .menu-button, .filter-button, .add-button {
    cursor: pointer;
}
.save-button:active, .close-button:active, .delete-button:active, .exec-button:active, .spe-button:active,
.filter-button:active, .table-action-btn:active { transform: scale(0.97); }

/* ---------- Small screens ---------------------------------------------- */

@media (max-width: 900px) {
    .toolbar-search, .toolbar-search:focus-within { width: 100%; order: -1; }
    .toolbar-btn-label { display: none; }
}

/* ---------- Respect reduced-motion preferences -------------------------- */

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

/* ==========================================================================
   Menu contextuel (clic droit)
   ========================================================================== */

.context-menu {
    min-width: 232px;
    max-width: 320px;
    padding: 6px;
    background: rgba(23, 24, 28, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 14px;
    box-shadow: 0 22px 54px rgba(0, 0, 0, 0.6), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
    z-index: 3000;
}
.context-menu:not(.hidden) { animation: uxMenuIn 0.12s var(--ux-ease); transform-origin: top left; }
@keyframes uxMenuIn { from { opacity: 0; transform: scale(0.96) translateY(-3px); } to { opacity: 1; transform: none; } }

.context-menu ul { margin: 0; padding: 0; list-style: none; }

.context-menu li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding: 0 10px;
    font-size: 13.5px;
    color: #e3e6ec;
    border-radius: 9px;
    cursor: pointer;
    outline: none;
    transition: background-color 0.1s ease, color 0.1s ease;
}
.context-menu li:hover,
.context-menu li:focus-visible,
.context-menu li.has-submenu:has(> .submenu-visible) { background: rgba(122, 167, 255, 0.16); color: #fff; }

.context-menu .menu-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 18px; margin: 0; font-size: 17px; color: #8f98a8; transition: color 0.1s ease; }
.context-menu .menu-icon svg { width: 16px; height: 16px; fill: currentColor; }
.context-menu li:hover > .menu-icon, .context-menu li:focus-visible > .menu-icon { color: #9dbfff; }
.context-menu .menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Titre du menu : nom de l'élément visé */
.context-menu li.menu-header {
    min-height: 0;
    padding: 6px 10px 8px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7d8596;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 0;
    cursor: default;
    pointer-events: none;
}

/* Action destructrice : séparée et en rouge */
.context-menu li.is-danger { margin-top: 5px; color: #fca5a5; }
.context-menu li.is-danger::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    top: -3px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}
.context-menu li.is-danger > .menu-icon { color: #f87171; }
.context-menu li.is-danger:hover, .context-menu li.is-danger:focus-visible { background: rgba(248, 113, 113, 0.17); color: #fecaca; }
.context-menu li.is-danger:hover > .menu-icon { color: #fca5a5; }

/* Sous-menus */
.context-menu li.has-submenu::after {
    content: "\203A";
    position: static;
    margin-left: auto;
    font-size: 18px;
    line-height: 1;
    color: #7d8596;
}
.context-menu li.has-submenu.submenu-left::after { content: "\2039"; left: auto; right: auto; }
.context-menu .submenu {
    left: calc(100% + 6px);
    top: -6px;
    width: max-content;
    min-width: 210px;
    max-width: 300px;
    max-height: min(360px, 70vh);
    overflow-y: auto;
    padding: 6px;
    background: rgba(23, 24, 28, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 14px;
    box-shadow: 0 22px 54px rgba(0, 0, 0, 0.6);
    cursor: default;
}
.context-menu .submenu.submenu-left { left: auto; right: calc(100% + 6px); }
.context-menu .submenu li::after { content: none; }
/* Pont invisible : le pointeur peut traverser l'espace entre menu et sous-menu */
.context-menu .submenu::before { content: ""; position: absolute; top: 0; bottom: 0; left: -8px; width: 8px; }
.context-menu .submenu.submenu-left::before { left: auto; right: -8px; }
.context-menu .submenu li.menu-header { padding: 8px 10px; border-bottom: none; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12.5px; }

.context-menu .menu-icon:empty { display: none; }
