/* Daily Framework Builder - Signature Utility Design */

/* --- Design Tokens --- */
:root {
    --df-accent: var(--clr-primary, #5B6DFB);
    --df-accent-light: rgba(91, 109, 251, 0.1);
    --df-border: var(--clr-border, #e5e7eb);
    --df-text-muted: var(--clr-ink-light, #6b7280);
    --df-success: var(--clr-success, #10b981);
    --df-warning: #f59e0b;
    --df-transition: 0.2s ease;
}

/* --- Box-sizing Reset (scoped to tool) --- */
.framework-container *,
.framework-container *::before,
.framework-container *::after {
    box-sizing: border-box;
}

/* --- Main Layout --- */
.framework-container {
    max-width: 980px;
    margin: 2rem auto;
    padding: 1.5rem;
}

/* Tool wrapper spacing */
.framework-tool-wrapper {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--df-border);
}

.tool-description {
    color: var(--df-text-muted);
    text-align: center;
    margin-bottom: 2rem;
}

/* --- Quick Build Header --- */
.quick-build-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--df-border);
}

.quick-build-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--clr-ink);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: var(--clr-background);
    border: 1px solid var(--df-border);
    border-radius: 20px;
    padding: 2px;
}

.mode-btn {
    padding: 0.375rem 1rem;
    border: none;
    background: transparent;
    color: var(--df-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 18px;
    cursor: pointer;
    transition: all var(--df-transition);
}

.mode-btn.active,
.mode-btn[aria-selected="true"] {
    background: var(--df-accent);
    color: white;
}

.mode-btn:hover:not(.active) {
    background: var(--df-accent-light);
}

.mode-btn:focus-visible {
    outline: 2px solid var(--df-accent);
    outline-offset: 2px;
}

/* --- Templates Bar --- */
.templates-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.template-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: white;
    border: 1px solid var(--df-border);
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--clr-ink);
    cursor: pointer;
    transition: all var(--df-transition);
    height: 38px;
}

.template-btn:hover {
    border-color: var(--df-accent);
    background: var(--df-accent-light);
    transform: translateY(-1px);
}

.template-btn:active {
    transform: translateY(0);
}

.template-icon {
    font-size: 1.125rem;
}

/* --- Quick Mode Panel --- */
.quick-mode-panel {
    margin-bottom: 2rem;
}

.quick-mode-panel[hidden] {
    display: none;
}

.quick-row {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--clr-surface);
    border: 1px solid var(--df-border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.quick-row-label {
    font-weight: 600;
    color: var(--clr-ink);
    flex-shrink: 0;
}

.quick-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.suggestion-chip {
    padding: 0.375rem 0.75rem;
    background: white;
    border: 1px solid var(--df-border);
    border-radius: 16px;
    font-size: 0.8125rem;
    color: var(--clr-ink);
    cursor: pointer;
    transition: all var(--df-transition);
    white-space: nowrap;
    height: 32px;
    display: inline-flex;
    align-items: center;
}

.suggestion-chip:hover {
    border-color: var(--df-accent);
    background: var(--df-accent-light);
}

.suggestion-chip:active {
    transform: scale(0.95);
}

.quick-add-form {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.quick-input {
    width: 160px;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--df-border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
    color: var(--clr-ink);
    height: 32px;
}

.quick-add-form .btn {
    height: 32px;
    padding: 0 0.75rem;
}

.quick-input:focus {
    outline: 2px solid var(--df-accent);
    outline-offset: 1px;
}

/* --- Framework Sections --- */
.framework-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Tablet: 2 columns */
@media (min-width: 769px) {
    .framework-sections {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: 3 columns */
@media (min-width: 1024px) {
    .framework-sections {
        grid-template-columns: repeat(3, 1fr);
    }
}

.framework-section {
    background: var(--clr-surface);
    border: 1px solid var(--df-border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.framework-section h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    color: var(--df-accent);
    position: relative;
}

.task-counter {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.875rem;
    font-weight: 400;
    padding: 0.125rem 0.5rem;
    background: var(--df-accent-light);
    border-radius: 10px;
    color: var(--df-accent);
}

.task-counter.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--df-warning);
}

.section-subtitle {
    margin: 0 0 1rem 0;
    font-size: 0.8125rem;
    color: var(--df-text-muted);
}

/* --- Task List --- */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    min-height: 100px;
}

.task-item {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    row-gap: 0.75rem;
    padding: 0.625rem;
    margin-bottom: 0.5rem;
    background: white;
    border: 1px solid var(--df-border);
    border-radius: 8px;
    transition: all var(--df-transition);
    cursor: move;
}

.task-item:hover {
    transform: translateX(2px);
    border-color: var(--df-accent);
}

.task-item.dragging {
    opacity: 0.5;
}

/* Drag Handle */
.drag-handle {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.25rem;
    cursor: grab;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle::before,
.drag-handle::after {
    content: '';
    width: 12px;
    height: 2px;
    background: var(--df-text-muted);
    border-radius: 1px;
}

/* Task Text */
.task-text {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--clr-ink);
    font-size: 0.9375rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Task Type Badge */
.task-type {
    padding: 0.125rem 0.375rem;
    border-radius: 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    flex-shrink: 0;
}

.task-type.flexible {
    background: var(--df-accent-light);
    color: var(--df-accent);
}

.task-type.fixed {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.task-type.transition {
    background: rgba(245, 158, 11, 0.1);
    color: var(--df-warning);
}

.task-type.body-needs {
    background: rgba(16, 185, 129, 0.1);
    color: var(--df-success);
}

/* Anchor Toggle */
.anchor-toggle {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--df-text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--df-transition);
    flex-shrink: 0;
}

.anchor-toggle.active {
    color: var(--df-warning);
}

.anchor-toggle:hover {
    transform: scale(1.1);
}

/* Sprint Link */
.sprint-link {
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--df-accent);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    text-decoration: none;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sprint link on new line for narrow rows */
@media (max-width: 360px) {
    .sprint-link {
        flex-basis: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

.sprint-link:hover {
    background: var(--df-accent);
    opacity: 0.9;
}

/* Delete Button */
.btn-delete {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity var(--df-transition);
    flex-shrink: 0;
}

.btn-delete:hover {
    opacity: 1;
}

/* Empty State */
.empty-state {
    padding: 1.5rem;
    text-align: center;
    color: var(--df-text-muted);
}

.empty-state span {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.empty-chips {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Add Buffer Button */
.add-buffer-btn {
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.5rem;
    background: transparent;
    border: 1px dashed var(--df-border);
    border-radius: 6px;
    color: var(--df-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--df-transition);
}

.add-buffer-btn:hover {
    border-color: var(--df-accent);
    background: var(--df-accent-light);
}

/* Limit Nudge */
.limit-nudge {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--df-warning);
    min-height: 42px;
}

/* --- Form Controls --- */
.add-task-form {
    display: flex;
    gap: 0.5rem;
}

.task-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--df-border);
    border-radius: 6px;
    font-size: 0.9375rem;
    background: white;
    color: var(--clr-ink);
}

.task-input:focus {
    outline: 2px solid var(--df-accent);
    outline-offset: 1px;
}

/* Add button with fixed width */
.add-task-form .btn {
    flex: 0 0 auto;
    min-width: 60px;
}

/* Stack on very narrow screens */
@media (max-width: 375px) {
    .add-task-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .add-task-form .btn {
        width: 100%;
    }
}

/* --- Action Buttons --- */
.framework-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--df-accent);
    text-decoration: underline;
    cursor: pointer;
    padding: 0.5rem;
}

.btn-link:hover {
    opacity: 0.8;
}

/* My Plan Option */
.myplan-option {
    text-align: center;
    margin-top: 1rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--clr-ink);
}

.checkbox-input {
    width: 18px;
    height: 18px;
    accent-color: var(--df-accent);
}

/* --- Messages & Toasts --- */
.success-message {
    text-align: center;
    padding: 1rem;
    margin-top: 1rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--df-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    font-weight: 600;
}

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--clr-ink);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
    pointer-events: auto;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.load-status {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--df-text-muted);
    font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .quick-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .quick-row-label {
        order: 1;
    }

    .quick-chips {
        order: 2;
    }

    .quick-add-form {
        order: 3;
        width: 100%;
    }

    .quick-input {
        width: 100%;
    }

    .templates-bar {
        flex-direction: column;
    }

    .template-btn {
        width: 100%;
        justify-content: center;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .task-item,
    .suggestion-chip,
    .template-btn,
    .mode-btn {
        transition: none !important;
    }

    .task-item:hover {
        transform: none;
    }

    .toast {
        animation: none;
    }
}

/* --- Focus States & Tab Order --- */
*:focus-visible {
    outline: 2px solid var(--df-accent);
    outline-offset: 2px;
}

/* Ensure proper tab order within task items */
.task-item .drag-handle { order: 1; }
.task-item .task-text { order: 2; }
.task-item .task-type { order: 3; }
.task-item .anchor-toggle { order: 4; }
.task-item .sprint-link { order: 5; }
.task-item .btn-delete { order: 6; }

/* --- Screen Reader Only --- */
.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;
}