/* ========================================
   TASKS + WEEKLY PLANNER STYLES
   Uniwersalny System Aktywnosci NinjaBot
   ======================================== */

/* Modal animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============ WEEKLY PLANNER ============ */

/* Override section defaults for planner - full bleed */
#section-cockpit.app-section.active {
    display: flex;
    flex-direction: column;
    padding: 0;
    max-width: none;
    min-height: calc(100vh - 50px);
}

/* Full-height container */
#cockpitContent {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.planner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}

.planner-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary, #1e293b);
}

.planner-header-subtitle {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 0;
    margin-left: 8px;
}

.planner-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Toggle buttons (3/5/7 days) */
.planner-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.planner-toggle-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.planner-toggle-btn:hover {
    color: #1e293b;
    background: #e2e8f0;
}

.planner-toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.planner-add-btn {
    padding: 8px 16px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition:
        opacity 0.2s,
        transform 0.1s;
}

.planner-add-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Banners (overdue, no outcome) */
.planner-banner {
    margin: 0 10px 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.planner-banner.overdue {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.planner-banner.no-outcome {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.planner-banner-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.planner-banner-items {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}

.planner-banner-item {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.planner-banner.overdue .planner-banner-item {
    background: #fee2e2;
}

.planner-banner.no-outcome .planner-banner-item {
    background: #fef3c7;
}

.planner-banner-action {
    padding: 4px 12px;
    border: 1px solid currentColor;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: inherit;
    margin-left: auto;
    white-space: nowrap;
}

/* Day Grid - FULL WIDTH, FULL HEIGHT */
.planner-grid {
    display: grid;
    margin: 0;
    border-top: 1px solid var(--border-light, #e2e8f0);
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    flex: 1;
    min-height: 0;
    background: #f8fafc;
}

.planner-day-col {
    border-right: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}

.planner-day-col:last-child {
    border-right: none;
}

/* Alternating column tint */
.planner-day-col:nth-child(even) {
    background: #fafbfd;
}

/* Weekend columns - warm tint */
.planner-day-col.weekend {
    background: #fefcf9;
}

.planner-day-col.weekend:nth-child(even) {
    background: #fdfaf6;
}

/* Today column - accent */
.planner-day-col.today {
    background: linear-gradient(180deg, #f3f0ff 0%, #f8f6ff 100%);
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.12);
}

/* Day header */
.planner-day-header {
    padding: 10px 14px;
    text-align: center;
    border-bottom: 2px solid #e9ecf1;
    background: #f1f4f8;
}

.planner-day-col:nth-child(even) .planner-day-header {
    background: #edf0f5;
}

.planner-day-col.weekend .planner-day-header {
    background: #f5f0eb;
    border-bottom-color: #e8dfd6;
}

.planner-day-col.today .planner-day-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-color: #5a6fd6;
}

.planner-day-name {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.5;
}

.planner-day-col.today .planner-day-name {
    opacity: 1;
}

.planner-day-num {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
}

/* ---- Combined weekend column ---- */
.planner-combined-col {
    background: #fefcf9;
}

.planner-combined-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 6px 8px;
}

.planner-combined-badge {
    flex: 1;
    text-align: center;
    padding: 4px 6px;
    border-radius: 6px;
}

.planner-combined-badge.today {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.planner-combined-badge.today .planner-day-name {
    opacity: 1;
}

.planner-combined-badge .planner-day-num {
    font-size: 14px;
}

.planner-combined-sep {
    width: 1px;
    height: 28px;
    background: #d4cdc6;
    margin: 0 4px;
    flex-shrink: 0;
}

.planner-combined-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, #d4cdc6 20%, #d4cdc6 80%, transparent);
    margin: 0;
}

.planner-combined-half {
    position: relative;
}

.planner-combined-half.today {
    background: linear-gradient(180deg, rgba(102, 126, 234, 0.04) 0%, transparent 100%);
}

.planner-combined-timeline {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Section labels within columns */
.planner-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8694a8;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.planner-day-col.today .planner-section-label {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    border-bottom-color: rgba(102, 126, 234, 0.08);
}

/* Timeline (hourly grid replacing old meetings section) */
.planner-timeline {
    position: relative;
    /* height set dynamically by JS based on CRM settings */
    overflow: hidden;
    padding-top: 6px; /* space for first hour label translateY(-6px) */
}

.planner-hour-row {
    display: flex;
    align-items: flex-start;
    /* height set dynamically by JS based on CRM settings (hour_height) */
    border-bottom: 1px solid #f1f5f9;
    box-sizing: border-box;
}

.planner-hour-label {
    width: 36px;
    font-size: 10px;
    color: #94a3b8;
    text-align: right;
    padding-right: 6px;
    flex-shrink: 0;
    line-height: 1;
    transform: translateY(-6px);
    user-select: none;
}

.planner-hour-cell {
    flex: 1;
    height: 100%;
    border-left: 1px solid #e2e8f0;
}

/* Current time indicator */
.planner-time-now {
    position: absolute;
    left: 36px;
    right: 0;
    height: 2px;
    background: #ef4444;
    z-index: 4;
    pointer-events: none;
}

.planner-time-now::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

/* Meeting card — absolutely positioned on timeline */
.planner-meeting-card {
    position: absolute;
    left: 40px;
    right: 4px;
    border-radius: 6px;
    background: #eff2ff;
    border-left: 3px solid #667eea;
    padding: 2px 8px;
    font-size: 12px;
    overflow: hidden;
    z-index: 2;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
}

.planner-meeting-card:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    z-index: 3;
}

.planner-meeting-card.phone {
    background: #fef9ee;
    border-left-color: #d97706;
}

.planner-meeting-card.video {
    background: #eff6ff;
    border-left-color: #2563eb;
}

.planner-meeting-card .meeting-time {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    flex-shrink: 0;
}

.planner-meeting-card .meeting-name {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.planner-meeting-card .meeting-outcome {
    font-size: 10px;
    flex-shrink: 0;
}

.planner-day-col.today .planner-meeting-card {
    border-left-color: #764ba2;
}

.planner-day-col.today .planner-meeting-card.phone {
    border-left-color: #d97706;
}

.planner-day-col.today .planner-meeting-card.video {
    border-left-color: #2563eb;
}

/* Tasks section (within column) */
.planner-tasks {
    padding: 0 8px 10px;
    border-top: none;
    background: rgba(0, 0, 0, 0.008);
}

/* Hidden tasks (collapsed by default when > 3) */
.planner-task-card.planner-task-hidden {
    display: none;
}

.planner-tasks.expanded .planner-task-card.planner-task-hidden {
    display: flex;
}

/* "Show more" button */
.planner-tasks-more {
    display: block;
    width: 100%;
    padding: 5px 8px;
    border: none;
    background: transparent;
    color: #667eea;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    border-radius: 6px;
    transition: background 0.15s;
}

.planner-tasks-more:hover {
    background: rgba(102, 126, 234, 0.08);
}

/* Toggle arrow in section label */
.planner-tasks-toggle {
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.2s;
}

/* Task card */
.planner-task-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: background 0.15s;
}

.planner-task-card:hover {
    background: rgba(102, 126, 234, 0.04);
}

.planner-task-check {
    width: 20px;
    height: 20px;
    border: 2px solid #d4d4d8;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: transparent;
    transition: all 0.15s;
    flex-shrink: 0;
}

.planner-task-check:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
}

.planner-task-info {
    flex: 1;
    min-width: 0;
}

.planner-task-title {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.planner-task-contact {
    font-size: 11px;
    color: #667eea;
    cursor: pointer;
    text-decoration: underline;
}

.planner-task-delete {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: #d4d4d8;
    border-radius: 6px;
    flex-shrink: 0;
    opacity: 0;
    transition: all 0.15s;
}

.planner-task-card:hover .planner-task-delete {
    opacity: 1;
}

.planner-task-delete:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* Task checkbox confirm state (double-click to complete) */
.planner-task-check.confirm {
    border-color: #22c55e;
    background: #22c55e;
    color: #fff;
    animation: confirmBounce 0.3s ease;
}

@keyframes confirmBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Priority dots */
.planner-priority-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.planner-priority-dot.high {
    background: #ef4444;
}
.planner-priority-dot.normal {
    background: #3b82f6;
}
.planner-priority-dot.low {
    background: #94a3b8;
}

/* Empty state per column */
.planner-empty-day {
    padding: 20px 12px;
    text-align: center;
    color: #d4d4d8;
    font-size: 13px;
    font-style: italic;
}

/* Unscheduled tasks section - bottom bar */
.planner-unscheduled {
    padding: 10px 20px;
    background: #fafbfc;
    border-top: 1px solid var(--border-light, #e2e8f0);
    flex-shrink: 0;
}

.planner-unscheduled-title {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.planner-unscheduled-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Stats bar */
.planner-stats {
    margin: 16px 28px 28px;
    background: linear-gradient(135deg, #f8fafc, #f0f4ff);
    border-radius: 14px;
    padding: 20px 24px;
}

.planner-stats h4 {
    margin: 0 0 14px;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.planner-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.planner-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #1e293b;
}

.planner-stat-label {
    font-size: 12px;
    color: #64748b;
}

.planner-stat-sub {
    font-size: 11px;
    color: #94a3b8;
}

/* ============ TASK DETAIL MODAL ============ */

.task-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.task-detail-modal {
    background: #fff;
    border-radius: 16px;
    width: 480px;
    max-width: 92vw;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.2s ease;
    overflow: hidden;
}

.task-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.task-detail-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-detail-type-icon {
    font-size: 18px;
}

.task-detail-type-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.task-detail-priority-badge {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.task-detail-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.15s;
}

.task-detail-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.task-detail-body {
    padding: 20px 24px;
}

.task-detail-title-input {
    width: 100%;
    padding: 10px 0;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    color: #1e293b;
    background: transparent;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.task-detail-title-input:focus {
    border-bottom-color: #667eea;
}

.task-detail-desc {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    color: #475569;
    resize: vertical;
    box-sizing: border-box;
    margin-top: 12px;
    transition: border-color 0.2s;
}

.task-detail-desc:focus {
    outline: none;
    border-color: #667eea;
}

.task-detail-meta {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.task-detail-meta-item label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.task-detail-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.task-detail-input:focus {
    outline: none;
    border-color: #667eea;
}

.task-detail-contact {
    margin-top: 14px;
    padding: 8px 12px;
    background: #f0f4ff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    cursor: pointer;
    transition: background 0.15s;
}

.task-detail-contact:hover {
    background: #e0e7ff;
}

.task-detail-footer-info {
    margin-top: 12px;
    font-size: 11px;
    color: #94a3b8;
}

.task-detail-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

.task-detail-actions-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.task-detail-btn {
    padding: 9px 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
}

.task-detail-btn.complete {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.task-detail-btn.complete:hover {
    background: #dcfce7;
}

.task-detail-btn.save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.task-detail-btn.save:hover {
    opacity: 0.9;
}

.task-detail-btn.save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.task-detail-btn.delete {
    background: transparent;
    color: #d4d4d8;
    padding: 9px 12px;
    font-size: 16px;
}

.task-detail-btn.delete:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
    .planner-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .planner-day-col {
        min-width: 80vw;
        scroll-snap-align: start;
        flex-shrink: 0;
    }

    .planner-header {
        padding: 12px 12px 10px;
    }

    .planner-banner {
        margin: 0 8px 6px;
    }

    .planner-unscheduled {
        padding: 10px 12px;
    }
}

@media (max-width: 600px) {
    .planner-header h2 {
        font-size: 18px;
    }

    .planner-toggle-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .planner-day-col {
        min-width: 85vw;
    }
}
