/* ============================================================================
   LAMINAIS - PRIORITY SUBTASK FEATURE STYLES
   ============================================================================
   Description: Styles for priority subtask highlighting, toggle buttons,
                and badge counters
   Date: December 16, 2025
   ============================================================================ */

/* ============================================================================
   CSS VARIABLES (customize these to match your theme)
   ============================================================================ */
:root {
    --priority-highlight-bg: #fffbcc;           /* Light yellow background */
    --priority-highlight-bg-hover: #fff9b3;     /* Darker yellow on hover */
    --priority-highlight-border: #ffd700;       /* Gold border */
    --priority-badge-bg: #ff9800;               /* Orange badge background */
    --priority-badge-text: #ffffff;             /* White badge text */
    --priority-icon-color: #ffc107;             /* Amber/gold icon color */
    --priority-icon-active: #ff9800;            /* Orange when active */
    --transition-speed: 0.3s;                   /* Animation speed */
    --badge-pulse-color: rgba(255, 152, 0, 0.4); /* Pulse animation color */
}

/* Dark mode overrides */
[data-theme="dark"] {
    --priority-highlight-bg: #4a4419;       /* Darker yellow for dark mode */
    --priority-highlight-bg-hover: #5a5422;
    --priority-highlight-border: #8b7500;
    --priority-badge-bg: #d68000;
    --priority-icon-color: #d68000;
    --priority-icon-active: #ff9800;
}

/* ============================================================================
   PRIORITY SUBTASK HIGHLIGHTING
   ============================================================================ */

/* Base subtask item styles (adjust selector to match your structure) */
.subtask-item {
    position: relative;
    padding-left: 40px !important; /* Make room for star and checkbox column */
    min-height: 48px; /* Ensure enough height for vertical stacking */
    transition: background-color var(--transition-speed) ease,
                border-color var(--transition-speed) ease,
                transform var(--transition-speed) ease;
}

/* Priority highlighted state */
.subtask-item.is-priority {
    background-color: var(--priority-highlight-bg) !important;
    border-left: 4px solid var(--priority-highlight-border);
    padding-left: calc(40px - 4px) !important; /* Compensate for border + make room for star */
}

/* Hover effect on priority subtasks */
.subtask-item.is-priority:hover {
    background-color: var(--priority-highlight-bg-hover) !important;
    transform: translateX(2px);
}

/* Smooth reordering animation when priority changes */
.subtask-item {
    animation: subtaskSlideIn 0.3s ease-out;
}

@keyframes subtaskSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   PRIORITY TOGGLE BUTTON
   ============================================================================ */

.subtask-priority-toggle {
    position: absolute;
    left: 8px;
    top: 50%; /* Center vertically */
    transform: translateY(6px); /* Move down to be below center */
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.2s ease;
    z-index: 5; /* Lower than checkbox */
}

.subtask-priority-toggle:hover {
    background-color: rgba(255, 193, 7, 0.1);
    transform: translateY(6px) scale(1.1);
}

.subtask-priority-toggle:active {
    transform: translateY(6px) scale(0.95);
}

.subtask-priority-toggle .priority-icon {
    font-size: 20px;
    color: var(--priority-icon-color);
    transition: color 0.2s ease, transform 0.2s ease;
}

/* Active priority state */
.subtask-item.is-priority .subtask-priority-toggle .priority-icon {
    color: var(--priority-icon-active);
    animation: starPulse 1s ease-in-out;
}

@keyframes starPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* Focus state for accessibility */
.subtask-priority-toggle:focus {
    outline: 2px solid var(--priority-icon-active);
    outline-offset: 2px;
}

/* ============================================================================
   CHECKBOX POSITIONING (to avoid overlap with star)
   ============================================================================ */

.subtask-checkbox {
    position: absolute;
    left: 8px; /* Same column as star */
    top: 50%; /* Center vertically */
    transform: translateY(-18px); /* Move up to be above center */
    z-index: 10; /* Higher than star button */
}

/* ============================================================================
   PRIORITY BADGE COUNTER ON PARENT TASK
   ============================================================================ */

.priority-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: var(--priority-badge-bg);
    color: var(--priority-badge-text);
    font-size: 12px;
    font-weight: 600;
    border-radius: 10px;
    margin-left: 8px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: badgeFadeIn 0.3s ease-out;
}

/* Badge fade-in animation */
@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse animation when badge count increases */
.priority-badge.updated {
    animation: badgePulse 0.5s ease-out;
}

@keyframes badgePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 0 8px var(--badge-pulse-color);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
}

/* Position badge in task header */
.task-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badge positioning within task card */
.task-card .priority-badge {
    flex-shrink: 0;
}

/* Hide badge with smooth transition */
.priority-badge[style*="display: none"] {
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

/* Mobile devices */
@media (max-width: 768px) {
    .subtask-priority-toggle {
        width: 36px;
        height: 36px;
    }

    .subtask-priority-toggle .priority-icon {
        font-size: 22px;
    }

    .priority-badge {
        min-width: 22px;
        height: 22px;
        font-size: 13px;
        padding: 0 7px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .subtask-item.is-priority {
        border-left-width: 3px;
        padding-left: calc(0.75rem - 3px);
    }

    .priority-badge {
        font-size: 11px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
    }
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

/* Skeleton loader for badges while loading */
.priority-badge.loading {
    background: linear-gradient(
        90deg,
        var(--priority-badge-bg) 0%,
        rgba(255, 152, 0, 0.6) 50%,
        var(--priority-badge-bg) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
}

@keyframes skeletonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .subtask-item.is-priority {
        border-left-width: 5px;
        border-color: #000;
    }

    .priority-badge {
        border: 2px solid #000;
    }
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .subtask-item,
    .subtask-priority-toggle,
    .priority-badge {
        transition: none;
        animation: none;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .subtask-priority-toggle {
        display: none;
    }

    .subtask-item.is-priority {
        background-color: transparent !important;
        border-left: 3px solid #000;
    }

    .priority-badge {
        background-color: #fff;
        color: #000;
        border: 1px solid #000;
    }
}

/* ============================================================================
   ADDITIONAL UTILITY CLASSES
   ============================================================================ */

/* Force show badge (for testing) */
.priority-badge.force-show {
    display: inline-flex !important;
    opacity: 1 !important;
}

/* Disabled state for toggle button */
.subtask-priority-toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.subtask-priority-toggle:disabled:hover {
    background-color: transparent;
    transform: translateY(-50%);
}

/* ============================================================================
   TOOLTIP STYLING (optional enhancement)
   ============================================================================ */

.subtask-priority-toggle[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 4px;
    z-index: 1000;
}

.priority-badge[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    margin-top: 4px;
    z-index: 1000;
}

/* ============================================================================
   TASK-LEVEL PRIORITY (parent task star toggle)
   ============================================================================ */

/* Priority toggle button on task cards */
.task-priority-toggle {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.2s ease;
    margin-right: 2px;
}

.task-priority-toggle:hover {
    background-color: rgba(255, 193, 7, 0.15);
    transform: scale(1.15);
}

.task-priority-toggle:active {
    transform: scale(0.9);
}

.task-priority-toggle .priority-icon {
    font-size: 18px;
    color: var(--priority-icon-color);
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
}

/* Active priority state — filled star */
.task-is-priority .task-priority-toggle .priority-icon {
    color: var(--priority-icon-active);
    animation: starPulse 0.6s ease-in-out;
}

/* Priority task card highlight */
.primer-card.task-is-priority {
    border-left: 4px solid var(--priority-highlight-border) !important;
    background-color: var(--priority-highlight-bg) !important;
}

.primer-card.task-is-priority:hover {
    background-color: var(--priority-highlight-bg-hover) !important;
}

/* Focus for accessibility */
.task-priority-toggle:focus {
    outline: 2px solid var(--priority-icon-active);
    outline-offset: 2px;
}

/* Mobile: larger tap target */
@media (max-width: 768px) {
    .task-priority-toggle {
        width: 36px;
        height: 36px;
    }

    .task-priority-toggle .priority-icon {
        font-size: 20px;
    }
}

/* Print: hide toggle */
@media print {
    .task-priority-toggle {
        display: none;
    }

    .primer-card.task-is-priority {
        border-left: 3px solid #000 !important;
        background-color: transparent !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .task-priority-toggle {
        transition: none;
    }

    .task-is-priority .task-priority-toggle .priority-icon {
        animation: none;
    }
}
