/* =====================================================
   MODAL & TOAST - Estilos para modales, detalles y toasts
   ===================================================== */

/* ── Overlay ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ── Modal Box ── */
.modal {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px 32px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal--wide {
    max-width: 920px;
    overflow: visible;
    max-height: none;
}

.modal--extra-wide {
    max-width: 850px;
    overflow: visible;
    max-height: none;
}

/* ── Panel lateral derecho (multimedia) ── */
.modal--panel-right {
    position: fixed;
    top: 2.5vh;
    right: 0;
    bottom: 2.5vh;
    left: auto;
    width: 24rem;
    max-width: 90vw;
    max-height: none;
    height: 95vh;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    overflow-y: auto;
    padding: 20px 16px;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,0.3) transparent;
}

.modal--panel-right::-webkit-scrollbar {
    width: 3px;
}
.modal--panel-right::-webkit-scrollbar-track {
    background: transparent;
}
.modal--panel-right::-webkit-scrollbar-thumb {
    background: rgba(99,102,241,0.3);
    border-radius: 4px;
}
.modal--panel-right::-webkit-scrollbar-thumb:hover {
    background: rgba(99,102,241,0.5);
}

.modal-overlay.active .modal--panel-right {
    transform: translateX(0);
}

/* Overlay para panel: alinear a la derecha */
.modal-overlay--panel-right {
    align-items: stretch;
    justify-content: flex-end;
}

/* ── Header ── */
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal__title {
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal__close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Form ── */
.modal__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: var(--fs-base);
    font-family: var(--font-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: none !important;
    min-height: 80px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Custom Select (Animated) ── */
.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select__trigger {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: var(--fs-base);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.custom-select__trigger:hover {
    border-color: var(--accent-primary);
}

.custom-select.active .custom-select__trigger {
    border-color: var(--accent-primary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.custom-select__options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--accent-primary);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    z-index: 9999;
    overflow-y: auto;
    max-height: 0;
    opacity: 0;
    transform: translateY(-10px);
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease, 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.custom-select__options::-webkit-scrollbar {
    width: 0;
    display: none;
}

.custom-select__options {
    scrollbar-width: none;
}

.custom-select.active .custom-select__options {
    max-height: 160px;
    opacity: 1;
    transform: translateY(0);
}

.custom-select__option {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.custom-select__option:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.custom-select__option.selected {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    font-weight: 600;
}

.custom-select__arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.custom-select.active .custom-select__arrow {
    transform: rotate(180deg);
}

.select-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Banner de rango de fechas en modal subtarea ── */
.subtask-range-note {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border-left: 3px solid var(--accent-primary);
    margin-bottom: 16px;
}

.custom-select--disabled {
    pointer-events: none;
    opacity: 0.7;
}

.custom-select--disabled .custom-select__trigger {
    background: var(--bg-surface);
    cursor: not-allowed;
}

/* ── Custom Checkboxes (Checklist) ── */
.checklist-scroll {
    max-height: 150px;
    overflow-y: auto;
    border: none;
    border-radius: 8px;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.checklist-scroll::-webkit-scrollbar {
    width: 4px;
}

.checklist-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.checklist-scroll::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.35);
    border-radius: 10px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.check-item:hover {
    background: var(--bg-elevated);
}

.check-item input[type="checkbox"] {
    display: none;
}

.check-box {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 5px;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.check-box::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transform: rotate(-45deg) scale(0);
    transition: all 0.2s ease;
    position: absolute;
    top: 3px;
    left: 2px;
}

.check-item input[type="checkbox"]:checked + .check-box {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.5);
}

.check-item input[type="checkbox"]:checked + .check-box::after {
    border-left-color: #fff;
    border-bottom-color: #fff;
    transform: rotate(-45deg) scale(1);
}

/* ── Modal Scrollbar (principal) ── */
.modal {
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.45) transparent;
}

.modal::-webkit-scrollbar {
    width: 5px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.45);
    border-radius: 10px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.65);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row>.form-group {
    flex: 1;
}

/* ── Actions ── */
.modal__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* ── Btn small ── */
.btn--sm {
    padding: 4px 10px;
    font-size: var(--fs-sm);
}

/* ══════════════════════════════════════════
   TASK DETAIL VIEW
   ══════════════════════════════════════════ */
.detail__layout {
    display: flex;
    gap: 28px;
}

.detail__main {
    flex: 1;
    min-width: 0;
}

.detail__sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
}

.detail__badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.detail__section {
    margin-bottom: 24px;
}

.detail__section-title {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.detail__description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.detail__progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail__empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--fs-sm);
    margin: 0;
}

/* Comments */
.detail__comment {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 10px;
}

.detail__comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: var(--fs-sm);
}

.detail__comment-header strong {
    color: var(--text-primary);
}

.detail__comment-time {
    color: var(--text-muted);
    font-size: 11px;
}

.detail__comment-text {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.detail__comment-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.detail__comment-form .form-input {
    flex: 1;
}

/* Attachments */
.detail__attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.detail__attachment-icon {
    font-size: 24px;
}

.detail__attachment-info {
    display: flex;
    flex-direction: column;
}

.detail__attachment-name {
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.detail__attachment-meta {
    color: var(--text-muted);
    font-size: 11px;
}

/* Sidebar info */
.detail__info-item {
    margin-bottom: 14px;
}

.detail__info-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail__info-value {
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: 500;
}

/* Table wrapping */
.detail__table-wrap {
    overflow: visible;
    margin: 0 -8px;
    padding: 0 8px;
}

/* ══════════════════════════════════════════
   CLICKABLE TASK ROWS
   ══════════════════════════════════════════ */
.task-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.task-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.06);
}

/* ══════════════════════════════════════════
   GRID HELPERS
   ══════════════════════════════════════════ */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--gap-md);
}

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--flag-on-track);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast--error {
    border-color: var(--accent-red);
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 700px) {
    .modal {
        width: 95%;
        padding: 20px;
    }

    .modal--wide {
        max-width: 95%;
        overflow-y: hidden;
    }

    .form-row {
        flex-direction: column;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .detail__layout {
        flex-direction: column;
    }

    .detail__sidebar {
        width: 100%;
    }
}

/* ── User List Scroll Wrap ── */
.users-scroll-wrap {
    max-height: calc(80vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.45) transparent;
    padding-right: 4px;
}
.users-scroll-wrap::-webkit-scrollbar {
    width: 4px;
}
.users-scroll-wrap::-webkit-scrollbar-track {
    background: transparent;
}
.users-scroll-wrap::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.45);
    border-radius: 10px;
}
.users-scroll-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.65);
}