/* Visual Timeline v0 Replica - v1 Interface Compliant */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    /* Removed bottom padding since nav is now at top */
}

#plugin-container {
    width: 100%;  /* Changed from max-width: 1400px to width: 100% */
    max-width: 100%;
    margin: 0;    /* Changed from 20px auto to 0 */
    background: white;
    border-radius: 0;  /* Changed from 16px to 0 for full width */
    box-shadow: none;
    overflow: hidden;
    overflow-x: hidden;
}

/* Hide header since we removed it from render method */
#header-container {
    display: none !important;
}

/* Full viewport width for timeline */
.visual-timeline-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Top Navigation */
.top-navigation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0;
    box-sizing: border-box;
}

.nav-grid {
    display: grid;
    grid-template-columns: 150px repeat(6, 1fr);
    align-items: center;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.nav-switcher {
    display: flex;
    gap: 8px;
    padding: 6px 15px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    margin-right: 0;
    width: 100%;
    justify-content: flex-start;
    box-sizing: border-box;
}

.nav-timeframe {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    padding: 6px;
    transition: opacity 0.2s ease;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-timeframe:last-child {
    border-right: none;
}

.nav-timeframe.hidden {
    opacity: 0;
    pointer-events: none;
}

.nav-timeframe.visible {
    opacity: 1;
}

.tab-btn {
    background: none;
    border: none;
    padding: 4px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 6px;
    border: 1px solid transparent;
}

.tab-btn:hover {
    color: #374151;
    background: rgba(0, 0, 0, 0.05);
}

.tab-btn.active {
    color: #3B82F6;
    border-color: #3B82F6;
    background: rgba(59, 130, 246, 0.1);
}

/* Add top margin to content to account for fixed nav */
.visual-timeline-acting,
.visual-timeline-planning {
    margin-top: 40px;
}

/* Acting Mode Styles */
.visual-timeline-acting {
    background: var(--surface-color);
    padding: 2rem;
    min-height: calc(100vh - 40px);
}

.acting-header {
    text-align: center;
    margin-bottom: 30px;
}

.acting-header h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.acting-header p {
    color: #7f8c8d;
    font-size: 1.1rem;
}

.task-timeline {
    width: 100%;  /* Changed from max-width: 800px to width: 100% */
    margin: 0 auto;
    padding: 0 20px;  /* Added padding for some breathing room */
}

.task-category {
    margin-bottom: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.category-header {
    background: var(--category-color);
    color: white;
    padding: 15px 20px;
    font-weight: 600;
    font-size: 1.1rem;
}

.task-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item:hover {
    background: #f8f9fa;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--category-color);
    border-radius: 50%;
    margin-right: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.task-checkbox:hover {
    background: rgba(52, 152, 219, 0.1);
}

.task-checkbox.completed {
    background: var(--category-color);
    position: relative;
}

.task-checkbox.completed::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 3px;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.task-content {
    flex: 1;
}

.task-title {
    font-size: 1rem;
    line-height: 1.4;
    color: #2c3e50;
    margin-bottom: 5px;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    color: #95a5a6;
}

.task-duration {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

/* Planning Mode Styles */
.visual-timeline-planning {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: calc(100vh - 40px);
    color: white;
    position: relative;
    padding: 0;
    margin-top: 40px;
    width: 100%;
}

.timeline-container {
    margin-top: 0;
    width: 100%;
    box-sizing: border-box;
}

/* lines between boxes - Using ID for singleton grid */
#myr-grid {
    display: grid;
    grid-template-columns: 150px repeat(6, 1fr);
    gap: 1px;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
    margin-top: 0;
}

.timeline-header {
    background: #f8f9fa;
    padding: 15px;
    font-weight: 600;
    text-align: center;
    border-right: 1px solid #e0e0e0;
    color: #2c3e50;
}

.timeline-header.category {
    background: #2c3e50;
    color: white;
    text-align: left;
}

/* Grid cells using BEM naming */
.myr-cell {
    position: relative;
    border: 1px solid #e0e0e0;
    background: #fafafa;
    min-height: 80px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align items to top */
    align-items: stretch; /* Stretch items to full width */
    gap: 4px;
    transition: background-color 0.2s ease;
}

.myr-cell:hover {
    background: #f0f0f0;
}

.myr-cell.today-cell {
    background: #fff3cd;
    border-color: #ffc107;
}

/* Cell content wrapper */
.myr-cell__content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align content to top */
    align-items: stretch; /* Stretch items to full width */
    gap: 4px;
    flex: 0 0 auto; /* Don't grow or shrink, use natural size */
}

/* Drop zones */
.myr-cell .drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border: 2px dashed transparent;
    transition: border-color 0.2s ease;
}

.myr-cell .drop-zone.drag-over {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.category-cell {
    background: var(--category-color);
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
    padding: 20px 15px;
}

.myr-task {
    background: white;
    border: 2px solid var(--milestone-color);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 4px 0;
    cursor: move;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.myr-task:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.myr-task.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.myr-task__content {
    font-size: 0.9rem;
    line-height: 1.3;
    color: #333;
    cursor: move;
}

/* Inline editor inside task should look native - Updated to spec-compliant class */
.myr-task__input {
    width: 100%;
    display: block;
    border: none;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.3;
    color: #333;
    background: transparent;
    overflow: hidden; /* hide scrollbar for autosize */
    resize: none;     /* disable manual resize */
    min-height: 28px;
    padding: 0;
}

/* Editing state: hide normal border while typing */
.myr-task--editing {
    border-style: dashed;
}

/* Base button styles for task buttons */
.myr-task__btn-left,
.myr-task__btn-right,
.myr-task__btn-delete {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: none !important; /* Force hide by default */
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.myr-task__btn-left {
    top: -8px;
    left: -8px;
    background: #3b82f6;
}

.myr-task__btn-right {
    top: -8px;
    left: 14px;
    background: #10b981;
}

.myr-task__btn-delete {
    top: -8px;
    right: -8px;
    background: #ef4444;
    font-size: 16px;
    font-weight: bold;
}

/* Show buttons on task hover */
.myr-task:hover .myr-task__btn-left,
.myr-task:hover .myr-task__btn-right,
.myr-task:hover .myr-task__btn-delete {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.myr-task__btn-left:hover {
    background: #2563eb;
}

.myr-task__btn-right:hover {
    background: #059669;
}

.myr-task__btn-delete:hover {
    background: #dc2626;
}

.myr-task__btn-left:active,
.myr-task__btn-right:active,
.myr-task__btn-delete:active {
    transform: scale(0.95);
}

.drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px dashed transparent;
    border-radius: 8px;
    transition: all 0.2s ease;
    pointer-events: none; /* purely visual overlay; don't intercept clicks */
}

/* drag and drop */
.drop-zone.drag-over {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.ongoing-badge {
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    position: absolute;
    top: -8px;
    right: -8px;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.stats {
    background: rgba(248, 249, 250, 0.95);
    padding: 20px 30px;
    border-top: 1px solid rgba(224, 224, 224, 0.5);
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-top: 5px;
}

/* Parent-child task styles - Updated to support both old and new spec classes */
.myr-task.myr-task--parent,
.myr-task.has-children {
    position: relative;
    padding-right: 24px; /* Make room for chevron on right */
}

/* Chevron for expandable tasks - actual element, not pseudo-element */
.myr-task__chevron {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--milestone-color);
    font-size: 12px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    user-select: none;
}

.myr-task__chevron:hover {
    transform: translateY(-50%) scale(1.2);
}

.myr-task.myr-task--child {
    margin-top: 4px;
    position: relative;
    border-left: 2px dashed var(--milestone-color);
}

/* Hide children when parent is not expanded - Support both old and new classes */
.myr-task.myr-task--parent:not(.expanded):not(.is-expanded) ~ .myr-task.myr-task--child,
.myr-task.has-children:not(.expanded):not(.is-expanded) ~ .myr-task.myr-task--child,
.myr-task.is-collapsed ~ .myr-task.myr-task--child {
    display: none;
}

/* Show children when parent is expanded - Support both old and new classes */
.myr-task.myr-task--parent.expanded ~ .myr-task.myr-task--child,
.myr-task.myr-task--parent.is-expanded ~ .myr-task.myr-task--child,
.myr-task.has-children.expanded ~ .myr-task.myr-task--child,
.myr-task.has-children.is-expanded ~ .myr-task.myr-task--child {
    display: block;
}

/* Drag-to-nest visual feedback */
.myr-task.nest-target {
    box-shadow: 0 0 0 2px var(--milestone-color);
    background: rgba(var(--milestone-color), 0.1);
}

.myr-task.nest-target::after {
    content: 'Drop to make sub-task';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--milestone-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 100;
}

/* Adjust task buttons for parent tasks - Support both old and new classes */
.myr-task.myr-task--parent .myr-task__btn-left,
.myr-task.myr-task--parent .myr-task__btn-right,
.myr-task.myr-task--parent .myr-task__btn-delete,
.myr-task.has-children .myr-task__btn-left,
.myr-task.has-children .myr-task__btn-right,
.myr-task.has-children .myr-task__btn-delete {
    top: -8px; /* Keep buttons at top to avoid overlap with chevron */
}

/* Dragging state for nested tasks */
.myr-task.myr-task--child.dragging {
    margin-left: 0;
    border-left: none;
}

/* Loading state for operations */
.myr-task.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.myr-task.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid var(--milestone-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translateY(-50%);
}

/* Error state for failed operations */
.myr-task.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: shake 0.5s ease-in-out;
}

/* Animations */
@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Error notification system */
.error-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #ef4444;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    max-width: 400px;
    font-size: 14px;
    line-height: 1.4;
    animation: slideInRight 0.3s ease-out;
}

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

/* Success notification variant */
.success-notification {
    background-color: #10b981;
}

/* Warning notification variant */
.warning-notification {
    background-color: #f59e0b;
}

/* Info notification variant */
.info-notification {
    background-color: #3b82f6;
}

/* Color schemes for categories */
.productivity {
    --category-color: #3498db;
    --milestone-color: #3498db;
}
.career {
    --category-color: #e74c3c;
    --milestone-color: #e74c3c;
}
.wealth {
    --category-color: #f39c12;
    --milestone-color: #f39c12;
}
.fitness {
    --category-color: #27ae60;
    --milestone-color: #27ae60;
}
.relationships {
    --category-color: #e91e63;
    --milestone-color: #e91e63;
}
.spiritual {
    --category-color: #9b59b6;
    --milestone-color: #9b59b6;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #7f8c8d;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.myr-cell.today-cell {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-right: 1px solid #e0e0e0;
}

.myr-cell.today-cell .drop-zone {
    background: rgba(255, 215, 0, 0.1);
    border: 2px dashed transparent;
}

.myr-cell.today-cell .drop-zone.drag-over {
    background: rgba(52, 152, 219, 0.1);
    border-color: #3498db;
    border-style: dashed;
}

@media (max-width: 768px) {
    .timeline-container {
        padding: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .legend {
        gap: 15px;
    }

    .stats {
        padding: 15px;
    }

    .timeline-grid {
        grid-template-columns: 150px repeat(5, 1fr);
        width: 100%;
    }
    
    /* Adjust for mobile */
    .milestone.is-child {
        padding-left: 16px; /* Use padding instead of margin */
    }
}
