/**
 * EnergyExperts Task Templates Styles
 * Styles for the template admin panel with Timeline/Gantt and Kanban views
 */

/* ============================================================================
   Admin Panel Container
   ============================================================================ */

.ee-tt-admin {
    padding: 1rem 0;
}

.ee-tt-loading,
.ee-tt-error,
.ee-tt-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary, #666);
}

.ee-tt-error {
    color: #dc3545;
}

.ee-tt-empty {
    background: var(--bg-light, #f8f9fa);
    border-radius: 8px;
    margin: 1rem 0;
}

.ee-tt-empty p {
    margin: 0.5rem 0;
}

/* ============================================================================
   Category Tabs
   ============================================================================ */

.ee-tt-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    padding-bottom: 1rem;
}

.ee-tt-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--bg-light, #f8f9fa);
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.ee-tt-tab:hover {
    background: var(--bg-hover, #e9ecef);
    border-color: var(--primary-color, #1f4566);
}

.ee-tt-tab.active {
    background: var(--primary-color, #1f4566);
    color: white;
    border-color: var(--primary-color, #1f4566);
}

.ee-tt-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
    font-size: 0.75rem;
    font-weight: 600;
}

.ee-tt-tab.active .ee-tt-tab-count {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   Toolbar
   ============================================================================ */

.ee-tt-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-light, #f8f9fa);
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.ee-tt-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ee-tt-toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ee-tt-category-label {
    color: var(--text-secondary, #666);
    font-size: 0.875rem;
}

.ee-tt-category-label strong {
    color: var(--text-primary, #333);
}

.ee-tt-template-count {
    color: var(--text-secondary, #666);
    font-size: 0.8rem;
}

/* View Switch Buttons */
.ee-tt-view-switch {
    display: flex;
    gap: 0.25rem;
    background: white;
    border-radius: 6px;
    padding: 0.25rem;
    border: 1px solid var(--border-color, #e0e0e0);
}

.ee-tt-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ee-tt-view-btn:hover {
    background: var(--bg-light, #f8f9fa);
    color: var(--primary-color, #1f4566);
}

.ee-tt-view-btn.active {
    background: var(--primary-color, #1f4566);
    color: white;
}

.ee-tt-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ee-tt-add-btn svg {
    flex-shrink: 0;
}

/* ============================================================================
   View Container
   ============================================================================ */

.ee-tt-view-container {
    min-height: 200px;
}

/* ============================================================================
   Timeline (Gantt) View
   ============================================================================ */

.ee-tt-timeline {
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
}

.ee-tt-timeline-header {
    display: flex;
    background: var(--bg-light, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    position: sticky;
    top: 0;
    z-index: 10;
}

.ee-tt-timeline-title-col {
    width: 280px;
    min-width: 280px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    border-right: 1px solid var(--border-color, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ee-tt-timeline-chart-col {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
}

.ee-tt-timeline-chart-inner {
    min-width: 100%;
}

.ee-tt-timeline-scale {
    display: flex;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.ee-tt-timeline-week {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    border-right: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-light, #f8f9fa);
    flex-shrink: 0;
    box-sizing: border-box;
}

.ee-tt-timeline-week:last-child {
    border-right: none;
}

.ee-tt-timeline-days {
    position: relative;
    height: 20px;
}

.ee-tt-timeline-day {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-secondary, #888);
    border-left: 1px solid var(--border-color, #e0e0e0);
    box-sizing: border-box;
}

.ee-tt-timeline-day:first-child {
    border-left: none;
}

.ee-tt-timeline-body {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Grid Lines (inside each row's bar-container) */
.ee-tt-timeline-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color, #e0e0e0);
    opacity: 0.4;
    pointer-events: none;
    z-index: 1;
}

.ee-tt-timeline-grid-line:nth-child(7n+1) {
    background: var(--primary-color, #1f4566);
    opacity: 0.2;
}

.ee-tt-timeline-row {
    display: flex;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    transition: background 0.2s ease;
}

.ee-tt-timeline-row:last-child {
    border-bottom: none;
}

.ee-tt-timeline-row:hover {
    background: var(--bg-light, #f8f9fa);
}

.ee-tt-timeline-row .ee-tt-timeline-title-col {
    font-weight: normal;
    padding: 0.5rem 1rem;
}

.ee-tt-timeline-task-info {
    flex: 1;
    min-width: 0;
}

.ee-tt-timeline-task-title {
    display: block;
    font-weight: 500;
    color: var(--text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
}

.ee-tt-timeline-task-days {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
}

.ee-tt-timeline-task-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ee-tt-timeline-row:hover .ee-tt-timeline-task-actions {
    opacity: 1;
}

.ee-tt-timeline-bar-container {
    position: relative;
    height: 100%;
    min-height: 50px;
    min-width: max-content;
    display: flex;
    align-items: center;
}

.ee-tt-timeline-bar {
    position: absolute;
    height: 28px;
    background: linear-gradient(135deg, var(--primary-color, #1f4566), #2a5a82);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
}

.ee-tt-timeline-bar:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ee-tt-timeline-bar.ee-tt-draggable {
    cursor: grab;
}

.ee-tt-timeline-bar.ee-tt-dragging {
    cursor: grabbing;
    opacity: 0.9;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    z-index: 100;
}

/* Resize Handles */
.ee-tt-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ee-tt-timeline-bar:hover .ee-tt-resize-handle,
.ee-tt-timeline-bar.ee-tt-dragging .ee-tt-resize-handle {
    opacity: 1;
}

.ee-tt-resize-left {
    left: 0;
    border-radius: 4px 0 0 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, transparent 100%);
}

.ee-tt-resize-right {
    right: 0;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(270deg, rgba(255,255,255,0.3) 0%, transparent 100%);
}

.ee-tt-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 12px;
    background: rgba(255,255,255,0.6);
    border-radius: 1px;
}

.ee-tt-timeline-bar-label {
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 0 1rem;
    pointer-events: none;
}

/* ============================================================================
   Kanban View
   ============================================================================ */

.ee-tt-kanban {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.ee-tt-kanban-column {
    background: var(--bg-light, #f8f9fa);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 300px;
}

.ee-tt-kanban-column[data-priority="high"] {
    border-top: 3px solid #dc3545;
}

.ee-tt-kanban-column[data-priority="medium"] {
    border-top: 3px solid #ffc107;
}

.ee-tt-kanban-column[data-priority="low"] {
    border-top: 3px solid #28a745;
}

.ee-tt-kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.ee-tt-kanban-header-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary, #333);
}

.ee-tt-kanban-header-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    background: white;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
}

.ee-tt-kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ee-tt-kanban-card {
    background: white;
    border-radius: 6px;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.ee-tt-kanban-card:hover {
    border-color: var(--primary-color, #1f4566);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.ee-tt-kanban-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.ee-tt-kanban-card-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary, #333);
    line-height: 1.3;
}

.ee-tt-kanban-card-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--secondary-color, #bff705);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    flex-shrink: 0;
}

.ee-tt-kanban-card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ee-tt-kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.ee-tt-kanban-card-days {
    font-size: 0.75rem;
    color: var(--primary-color, #1f4566);
    font-weight: 500;
}

.ee-tt-kanban-card-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ee-tt-kanban-card:hover .ee-tt-kanban-card-actions {
    opacity: 1;
}

/* ============================================================================
   Icon Buttons (shared)
   ============================================================================ */

.ee-tt-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-light, #f8f9fa);
    color: var(--text-secondary, #666);
}

.ee-tt-btn-icon:hover {
    background: var(--bg-hover, #e9ecef);
}

.ee-tt-btn-icon.ee-tt-btn-edit:hover {
    background: var(--primary-color, #1f4566);
    color: white;
}

.ee-tt-btn-icon.ee-tt-btn-delete:hover {
    background: #dc3545;
    color: white;
}

/* ============================================================================
   Popup / Dialog
   ============================================================================ */

.ee-tt-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.ee-tt-popup {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ee-tt-load-dialog {
    max-width: 450px;
}

.ee-tt-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.ee-tt-popup-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text-primary, #333);
}

.ee-tt-popup-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary, #666);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.ee-tt-popup-close:hover {
    background: var(--bg-light, #f8f9fa);
    color: var(--text-primary, #333);
}

.ee-tt-popup-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.ee-tt-popup-body .form-group {
    margin-bottom: 1rem;
}

.ee-tt-popup-body .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.ee-tt-popup-body .form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.ee-tt-popup-body .form-input:focus {
    outline: none;
    border-color: var(--primary-color, #1f4566);
}

.ee-tt-popup-body .form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.ee-tt-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-light, #f8f9fa);
}

/* ============================================================================
   Load Dialog - Category List
   ============================================================================ */

.ee-tt-category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.ee-tt-category-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-light, #f8f9fa);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ee-tt-category-checkbox:hover {
    background: var(--bg-hover, #e9ecef);
}

.ee-tt-category-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ee-tt-category-checkbox input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.ee-tt-category-checkbox span:first-of-type {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.ee-tt-category-count {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
}

/* ============================================================================
   Expandable Category Groups (Load Dialog)
   ============================================================================ */

.ee-tt-category-group {
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
}

.ee-tt-category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-light, #f8f9fa);
}

.ee-tt-category-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #666);
    padding: 0.75rem 0.5rem;
}

.ee-tt-category-toggle:hover {
    color: var(--primary-color, #1f4566);
    background: rgba(0, 0, 0, 0.05);
}

.ee-tt-toggle-icon {
    transition: transform 0.2s ease;
}

.ee-tt-category-header .ee-tt-category-checkbox {
    flex: 1;
    padding: 0.75rem 1rem 0.75rem 0;
    background: transparent;
    border-radius: 0;
}

.ee-tt-category-header .ee-tt-category-checkbox:hover {
    background: transparent;
}

.ee-tt-category-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.ee-tt-duplicate-hint {
    font-size: 0.7rem;
    color: #f59e0b;
    background: #fef3c7;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 0.5rem;
}

.ee-tt-category-tasks {
    border-top: 1px solid var(--border-color, #e0e0e0);
    background: white;
    max-height: 300px;
    overflow-y: auto;
}

.ee-tt-task-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.ee-tt-task-checkbox:last-child {
    border-bottom: none;
}

.ee-tt-task-checkbox:hover {
    background: var(--bg-light, #f8f9fa);
}

.ee-tt-task-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.ee-tt-task-title {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary, #333);
}

.ee-tt-task-days {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
}

.ee-tt-task-checkbox.duplicate {
    background: #fef3c7;
}

.ee-tt-task-checkbox.duplicate:hover {
    background: #fde68a;
}

.ee-tt-task-checkbox.duplicate .ee-tt-task-title {
    color: #92400e;
}

.ee-tt-duplicate-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    background: #f59e0b;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.ee-tt-load-info {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.ee-tt-load-info strong {
    color: var(--primary-color, #1f4566);
    font-size: 1.1em;
}

.ee-tt-info-duplicates {
    color: #f59e0b;
    font-size: 0.85em;
    margin-left: 0.5rem;
}

.ee-tt-load-count {
    font-weight: 600;
}

/* ============================================================================
   Load Templates Button (in Project View)
   ============================================================================ */

.ee-tn-load-templates-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color, #1f4566);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.ee-tn-load-templates-btn:hover {
    background: var(--primary-dark, #153347);
}

.ee-tn-load-templates-btn svg {
    flex-shrink: 0;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 900px) {
    .ee-tt-kanban {
        grid-template-columns: 1fr;
    }

    .ee-tt-kanban-column {
        min-height: auto;
    }
}

@media (max-width: 768px) {
    .ee-tt-timeline-title-col {
        width: 200px;
        min-width: 200px;
    }

    .ee-tt-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ee-tt-toolbar-left,
    .ee-tt-toolbar-right {
        justify-content: space-between;
    }
}

@media (max-width: 600px) {
    .ee-tt-tabs {
        gap: 0.25rem;
    }

    .ee-tt-tab {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    .ee-tt-tab-count {
        min-width: 20px;
        height: 20px;
        font-size: 0.625rem;
    }

    .ee-tt-popup-body .form-row {
        grid-template-columns: 1fr;
    }

    .ee-tt-timeline-title-col {
        width: 150px;
        min-width: 150px;
    }

    .ee-tt-timeline-task-actions,
    .ee-tt-kanban-card-actions {
        opacity: 1;
    }
}
