@import url('../shared/global.css');

:root {
    --sidebar-width: 280px;
    --header-height: 64px;
    --task-item-padding: 12px 0;
}

body {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-top: 64px; /* Account for fixed topbar */
}

#app {
    display: flex;
    width: 100%;
    flex-grow: 1;
    overflow: hidden;
}

/* Sidebar */

#sidebar {
    width: var(--sidebar-width);
    background-color: var(--workspace-sidebar-bg, var(--md-sys-color-surface-container));
    display: flex;
    flex-direction: column;
    padding: 16px;
    height: calc(100vh - 64px);
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    z-index: 900;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.sidebar-header h2 {
    font-size: 22px;
    font-weight: 500;
    margin: 0 0 24px 12px;
    color: var(--md-sys-color-on-surface);
}

#refresh-groups-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 100px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    transition: background-color 0.2s;
}

.group-item .material-symbols-rounded {
    font-size: 24px;
}

.group-item:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.group-item.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.sidebar-action {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    cursor: pointer;
    border-radius: 100px;
    margin-top: 8px;
}

.sidebar-action:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

/* Main Content */

#main-content {
    margin-left: var(--sidebar-width);
    margin-top: 0;
    height: calc(100vh - 64px);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px;
    background-color: var(--md-sys-color-surface);
}

/* When sidebar is collapsed */
body.sidebar-collapsed #main-content {
    margin-left: 0;
}

.task-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#current-list-title {
    font-size: 32px;
    font-weight: 400;
    margin: 0;
}

/* Add Task Input */
.add-task-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 32px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 8px;
    max-height: 72px;
    min-height: 56px;
    flex-shrink: 0;
    box-sizing: border-box;
    background-color: var(--md-sys-color-surface-container-lowest);
}

.add-task-container:focus-within {
    box-shadow: 0 1px 3px color-mix(in srgb, var(--md-sys-color-shadow) 12%, transparent), 0 1px 2px color-mix(in srgb, var(--md-sys-color-shadow) 24%, transparent);
    background-color: var(--md-sys-color-surface-container-lowest);
}

.add-icon {
    font-size: 24px;
    color: var(--md-sys-color-primary);
}

#new-task-input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    width: 100%;
    outline: none;
    color: var(--md-sys-color-on-surface);
}

#tasks-container {
    width: 100%;
    max-width: 600px;
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 40px;
}

.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 0;
    gap: 16px;
    border-bottom: 1px solid rgba(121, 116, 126, 0.12);
    /* Very subtle divider */
    transition: opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease, max-height 0.3s ease;
    max-height: 200px;
    /* Arbitrary large enough height for animation */
    overflow: hidden;
    cursor: grab;
}

.task-item:active {
    cursor: grabbing;
}

@keyframes taskDeepLinkPulse {
    0% {
        background-color: rgba(103, 80, 164, 0);
        background-color: color-mix(in srgb, transparent 100%, var(--md-sys-color-primary));
        box-shadow: inset 0 0 0 0 rgba(103, 80, 164, 0);
        box-shadow: inset 0 0 0 0 color-mix(in srgb, transparent 100%, var(--md-sys-color-primary));
    }

    25% {
        background-color: rgba(103, 80, 164, 0.10);
        background-color: color-mix(in srgb, transparent 90%, var(--md-sys-color-primary));
        box-shadow: inset 0 0 0 2px rgba(103, 80, 164, 0.22);
        box-shadow: inset 0 0 0 2px color-mix(in srgb, transparent 78%, var(--md-sys-color-primary));
    }

    100% {
        background-color: rgba(103, 80, 164, 0);
        background-color: color-mix(in srgb, transparent 100%, var(--md-sys-color-primary));
        box-shadow: inset 0 0 0 0 rgba(103, 80, 164, 0);
        box-shadow: inset 0 0 0 0 color-mix(in srgb, transparent 100%, var(--md-sys-color-primary));
    }
}

.task-item.deep-link-focus {
    border-radius: 12px;
    animation: taskDeepLinkPulse 1.1s ease-out;
}

.task-item.sliding-up {
    opacity: 0;
    margin: 0;
    padding: 0;
    max-height: 0;
    border-bottom: 0px solid transparent;
}

/* Checkbox Styling */
.task-checkbox {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--md-sys-color-outline);
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    margin-top: 4px;
    /* Align with text top */
    transition: all 0.2s;
}

.task-checkbox:checked {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

.task-checkbox:checked::after {
    content: 'check';
    font-family: 'Material Symbols Outlined';
    font-size: 14px;
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
}

.task-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.task-text {
    font-size: 16px;
    line-height: 24px;
    color: var(--md-sys-color-on-surface);
}

.task-details {
    font-size: 12px;
    color: var(--md-sys-color-outline);
    margin-top: 4px;
}

.task-actions {
    opacity: 0;
    transition: opacity 0.2s;
}

.task-item:hover .task-actions {
    opacity: 1;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-outline);
    padding: 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.action-btn:hover {
    color: var(--md-sys-color-on-surface);
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 5%, transparent);
}

.delete-btn:hover {
    color: var(--md-sys-color-error);
    background-color: color-mix(in srgb, var(--md-sys-color-error) 8%, transparent);
    /* specific red hover for delete */
}

/* Completed Section */

#completed-section {
    margin-top: 24px;
}

.completed-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.clear-completed-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface-variant);
    font: inherit;
    cursor: pointer;
}

.clear-completed-btn .material-symbols-rounded {
    font-size: 18px;
}

.clear-completed-btn:hover {
    background: var(--md-sys-color-surface-container-high);
}

.completed-header:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 2%, transparent);
}

.completed-header .material-symbols-rounded {
    transition: transform 0.2s;
}

.completed-header.collapsed #completed-arrow {
    transform: rotate(-90deg);
}

.completed-header h3 {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

/* Task Edit Input */
.task-edit-input {
    font-family: inherit;
    font-size: 16px;
    line-height: 24px;
    color: var(--md-sys-color-on-surface);
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--md-sys-color-primary);
    outline: none;
    width: 100%;
    padding: 0;
    margin: 0;
}

/* Completed Task Styles */
.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--md-sys-color-outline);
}

.task-item.completed {
    border-bottom: none;
    /* Often completed items don't have separators or they are different */
}

/* Context Menu */
.context-menu {
    position: absolute;
    z-index: 10002;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: 8px;
    box-shadow: 0 4px 6px color-mix(in srgb, var(--md-sys-color-shadow) 10%, transparent), 0 1px 3px color-mix(in srgb, var(--md-sys-color-shadow) 8%, transparent);
    /* Elevation 3 appx */
    min-width: 180px;
    padding: 8px 0;
    overflow: hidden;
    animation: fadeIn 0.1s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.context-menu-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    transition: background-color 0.1s;
}

.context-menu-item:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.context-menu-item.delete {
    color: var(--md-sys-color-error, #ba1a1a);
}

.context-menu-item.delete:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-error) 8%, transparent);
}

.context-menu-item .material-symbols-rounded {
    font-size: 20px;
}

.context-divider {
    height: 1px;
    background-color: var(--md-sys-color-outline);
    opacity: 0.12;
    margin: 4px 0;
}

/* Icon Picker Modal */
.icon-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: color-mix(in srgb, var(--md-sys-color-scrim) 50%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.icon-picker-content {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: 16px;
    box-shadow: 0 8px 16px color-mix(in srgb, var(--md-sys-color-shadow) 20%, transparent);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.icon-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.icon-picker-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.icon-picker-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.icon-picker-close:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 5%, transparent);
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 16px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.icon-picker-item {
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.icon-picker-item .material-symbols-rounded {
    font-size: 28px;
    color: var(--md-sys-color-on-surface);
}

.icon-picker-item:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 5%, transparent);
    border-color: var(--md-sys-color-outline-variant);
}

.icon-picker-item.selected {
    background-color: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
}

.icon-picker-item.selected .material-symbols-rounded {
    color: var(--md-sys-color-on-primary-container);
}

/* Hide scrollbars but keep scrolling functionality */
#main-content::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar,
#refresh-groups-list::-webkit-scrollbar,
#tasks-container::-webkit-scrollbar,
.icon-picker-grid::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

#main-content,
.sidebar-content,
#refresh-groups-list,
#tasks-container,
.icon-picker-grid {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
