/**
 * Calendar Page Styles - 2 Column Layout
 * Matches Figma design with responsive breakpoints
 * VERSION: 2025-12-19-v5 (Source filter tabs)
 */

/* ============================================
   PAGE LAYOUT - 2 COLUMNS
   ============================================ */

.calendar-page {
    height: calc(100vh - 64px);
    padding: 0;
    overflow: hidden;
    background: #F9FAFB;
}

.calendar-layout {
    display: grid;
    grid-template-columns: 384px 4px 1fr;
    height: 100%;
}

/* Resize Handle */
.calendar-resize-handle {
    width: 4px;
    background: #E5E7EB;
    cursor: col-resize;
    position: relative;
    transition: background 0.15s ease;
}

.calendar-resize-handle:hover,
.calendar-resize-handle.dragging {
    background: #155DFC;
}

.calendar-resize-handle::before {
    content: '';
    position: absolute;
    left: -4px;
    right: -4px;
    top: 0;
    bottom: 0;
}

/* ============================================
   LEFT PANEL - FILTERS & EVENT LIST
   ============================================ */

.calendar-list-panel {
    background: #FFFFFF;
    border-right: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search */
.calendar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid #E5E7EB;
}

.calendar-search img {
    opacity: 0.5;
    flex-shrink: 0;
}

.calendar-search-input {
    flex: 1;
    border: 1px solid #D1D5DB;
    border-radius: 10px;
    padding: 8px 16px 8px 8px;
    font-size: 14px;
    color: #111827;
    background: transparent;
}

.calendar-search-input:focus {
    outline: none;
    border-color: #155DFC;
}

.calendar-search-input::placeholder {
    color: rgba(10, 10, 10, 0.5);
}

/* Filters Section */
.calendar-filters-section {
    padding: 16px;
    border-bottom: 1px solid #E5E7EB;
}

.calendar-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.calendar-filters-title {
    font-size: 12px;
    font-weight: 500;
    color: #6A7282;
    text-transform: uppercase;
    margin: 0;
}

.calendar-sync-time {
    font-size: 11px;
    color: #9CA3AF;
    font-weight: 400;
}

/* Status Filters */
.calendar-status-filters {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calendar-status-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.calendar-status-btn:hover {
    background: #F3F4F6;
}

.calendar-status-btn.active {
    background: #EFF6FF;
}

.calendar-status-btn.active .calendar-status-label {
    color: #1447E6;
    font-weight: 500;
}

.calendar-status-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #364153;
}

.calendar-status-count {
    font-size: 12px;
    font-weight: 500;
    color: #364153;
    background: #E5E7EB;
    padding: 2px 8px;
    border-radius: 9999px;
    min-width: 24px;
    text-align: center;
}

.calendar-status-btn.active .calendar-status-count {
    background: #BEDBFF;
    color: #1447E6;
}

/* Source Filters (All Events / Needs Review) */
.calendar-source-filters {
    display: flex;
    gap: 4px;
    background: #F3F4F6;
    border-radius: 10px;
    padding: 4px;
}

.calendar-source-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    justify-content: center;
}

.calendar-source-btn:hover {
    background: #E5E7EB;
}

.calendar-source-btn.active {
    background: #FFFFFF;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.calendar-source-label {
    font-size: 14px;
    font-weight: 500;
    color: #6B7280;
}

.calendar-source-btn.active .calendar-source-label {
    color: #111827;
}

.calendar-source-badge {
    font-size: 12px;
    font-weight: 600;
    color: #FFFFFF;
    background: #155DFC;
    padding: 2px 8px;
    border-radius: 9999px;
    min-width: 20px;
    text-align: center;
}

.calendar-source-btn:not(.active) .calendar-source-badge {
    background: #6B7280;
}

/* Priority Filters */
.calendar-priority-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.calendar-priority-btn {
    padding: 4px 12px;
    font-size: 14px;
    font-weight: 500;
    text-transform: capitalize;
    border: none;
    border-radius: 10px;
    background: #F3F4F6;
    color: #364153;
    cursor: pointer;
    transition: all 0.15s ease;
}

.calendar-priority-btn:hover {
    background: #E5E7EB;
}

.calendar-priority-btn.active {
    background: #155DFC;
    color: #FFFFFF;
}

/* Event List */
.calendar-item-list {
    flex: 1;
    overflow-y: auto;
}

/* Event Sections */
.calendar-section {
    border-bottom: 1px solid #E5E7EB;
}

.calendar-section:last-child {
    border-bottom: none;
}

.calendar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #F9FAFB;
    border-bottom: 1px solid #E5E7EB;
}

.calendar-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-section-count {
    font-size: 12px;
    font-weight: 500;
    color: #9CA3AF;
    background: #E5E7EB;
    padding: 2px 8px;
    border-radius: 10px;
}

.calendar-section-empty {
    padding: 24px 16px;
    text-align: center;
    color: #9CA3AF;
    font-size: 14px;
}

/* Collapsible Section */
.calendar-section-toggle {
    cursor: pointer;
    user-select: none;
}

.calendar-section-toggle:hover {
    background: #F3F4F6;
}

.calendar-section-chevron {
    transition: transform 0.2s ease;
}

.calendar-section-collapsible.expanded .calendar-section-chevron {
    transform: rotate(90deg);
}

/* Personal events have slightly muted styling */
.calendar-section-collapsible .calendar-item {
    opacity: 0.85;
}

.calendar-section-collapsible .calendar-item:hover {
    opacity: 1;
}

/* Event Item */
.calendar-item {
    display: block;
    padding: 16px;
    border-bottom: 1px solid #E5E7EB;
    cursor: pointer;
    transition: background 0.15s ease;
}

.calendar-item:hover {
    background: #F9FAFB;
}

.calendar-item.selected {
    background: #EFF6FF;
}

.calendar-item-header {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.calendar-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.calendar-item-icon.blue {
    background: #DBEAFE;
}

.calendar-item-icon.purple {
    background: #F3E8FF;
}

.calendar-item-icon.green {
    background: #DCFCE7;
}

.calendar-item-icon.orange {
    background: #FFEDD5;
}

.calendar-item-icon img,
.calendar-item-icon svg {
    width: 16px;
    height: 16px;
}

.calendar-item-info {
    flex: 1;
    min-width: 0;
}

.calendar-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #101828;
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-item-customer {
    font-size: 13px;
    font-weight: 400;
    color: #6A7282;
    margin: 0;
}

.calendar-item-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.calendar-item-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6A7282;
}

.calendar-item-meta-item svg {
    width: 14px;
    height: 14px;
    color: #9CA3AF;
}

.calendar-item-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.calendar-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 8px;
}

.calendar-tag-agent {
    background: #F3F4F6;
    color: #364153;
}

.calendar-tag-agent svg {
    width: 12px;
    height: 12px;
}

.calendar-tag-confidence {
    background: #D1FAE5;
    color: #065F46;
}

.calendar-tag-confidence-low {
    background: #FEF3C7;
    color: #92400E;
}

.calendar-tag-priority-high {
    background: #FEE2E2;
    color: #991B1B;
}

.calendar-tag-priority-medium {
    background: #FEF3C7;
    color: #92400E;
}

.calendar-tag-priority-low {
    background: #D1FAE5;
    color: #065F46;
}

/* ============================================
   RIGHT PANEL - EVENT DETAIL
   ============================================ */

.calendar-detail-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #F9FAFB;
    padding: 24px;
    gap: 16px;
    height: 100%;
    max-height: 100%;
}

/* Event Header Card */
.calendar-header-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 16px 20px;
    flex-shrink: 0;
}

.calendar-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.calendar-header-title-section {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.calendar-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.calendar-header-icon.blue {
    background: #DBEAFE;
}

.calendar-header-icon.purple {
    background: #F3E8FF;
}

.calendar-header-icon.green {
    background: #DCFCE7;
}

.calendar-header-icon.orange {
    background: #FFEDD5;
}

.calendar-header-icon img,
.calendar-header-icon svg {
    width: 24px;
    height: 24px;
}

.calendar-header-info {
    flex: 1;
    min-width: 0;
}

.calendar-detail-title {
    font-size: 18px;
    font-weight: 600;
    color: #101828;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.calendar-detail-customer {
    font-size: 14px;
    font-weight: 500;
    color: #364153;
    margin: 0;
}

.calendar-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.calendar-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #155DFC;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.calendar-action-btn:hover {
    background: #1447E6;
}

.calendar-action-btn:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
}

.calendar-action-btn-secondary {
    background: #F3F4F6;
    color: #364153;
}

.calendar-action-btn-secondary:hover {
    background: #E5E7EB;
}

.calendar-action-btn-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.calendar-action-btn-danger:hover {
    background: #FECACA;
}

.calendar-header-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 12px 0;
}

/* Event Meta Grid */
.calendar-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}

.calendar-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.calendar-meta-icon {
    width: 16px;
    height: 16px;
    color: #6A7282;
    flex-shrink: 0;
    margin-top: 2px;
}

.calendar-meta-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-meta-label {
    font-size: 12px;
    font-weight: 500;
    color: #6A7282;
}

.calendar-meta-value {
    font-size: 14px;
    font-weight: 500;
    color: #101828;
}

/* Tags Row */
.calendar-tags-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.calendar-detail-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #F3F4F6;
    border-radius: 10px;
    font-size: 13px;
    color: #364153;
}

.calendar-detail-tag svg {
    width: 16px;
    height: 16px;
    color: #6A7282;
}

.calendar-detail-tag-remove {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #9CA3AF;
    display: flex;
    align-items: center;
}

.calendar-detail-tag-remove:hover {
    color: #EF4444;
}

.calendar-add-tag-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: #6A7282;
    cursor: pointer;
}

.calendar-add-tag-btn:hover {
    color: #155DFC;
}

/* Detail Content Area */
.calendar-detail-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

/* Cards */
.calendar-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
}

.calendar-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #E5E7EB;
    gap: 12px;
    flex-wrap: wrap;
}

.calendar-card-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.calendar-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #101828;
    margin: 0;
}

.calendar-card-body {
    padding: 16px;
}

.calendar-card-text {
    font-size: 14px;
    line-height: 1.7;
    color: #364153;
    white-space: pre-wrap;
    margin: 0;
}

/* AI Summary Card */
.calendar-ai-card .calendar-card-header {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.05) 0%, rgba(99, 102, 241, 0) 100%);
}

.calendar-confidence-badge {
    font-size: 14px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 9999px;
}

.calendar-confidence-badge.high {
    background: #D1FAE5;
    color: #065F46;
}

.calendar-confidence-badge.medium {
    background: #FEF3C7;
    color: #92400E;
}

.calendar-confidence-badge.low {
    background: #FEE2E2;
    color: #991B1B;
}

/* Notes Section */
.calendar-notes-section {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 12px 16px;
    margin-top: 12px;
}

.calendar-notes-label {
    font-size: 13px;
    font-weight: 600;
    color: #364153;
    margin: 0 0 4px;
}

.calendar-notes-text {
    font-size: 13px;
    color: #6A7282;
    margin: 0;
}

/* Follow-up Actions */
.calendar-actions-card .calendar-card-header {
    background: #F9FAFB;
}

.calendar-actions-list {
    display: flex;
    flex-direction: column;
}

.calendar-action-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #E5E7EB;
}

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

.calendar-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #EFF6FF;
}

.calendar-action-icon svg {
    width: 16px;
    height: 16px;
    color: #155DFC;
}

.calendar-action-info {
    flex: 1;
    min-width: 0;
}

.calendar-action-type {
    font-size: 12px;
    font-weight: 500;
    color: #6A7282;
    text-transform: uppercase;
    padding: 2px 6px;
    background: #F3F4F6;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 4px;
}

.calendar-action-title {
    font-size: 14px;
    font-weight: 600;
    color: #101828;
    margin: 0 0 8px;
}

.calendar-action-preview {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    color: #364153;
    line-height: 1.5;
}

.calendar-action-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.calendar-approve-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #10B981;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.calendar-approve-btn:hover {
    background: #059669;
}

.calendar-reject-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #F3F4F6;
    color: #364153;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.calendar-reject-btn:hover {
    background: #E5E7EB;
}

/* Approve All Button */
.calendar-approve-all-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #155DFC;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.calendar-approve-all-btn:hover {
    background: #1447E6;
}

/* Empty State */
.calendar-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6A7282;
    padding: 40px;
}

.calendar-empty-state svg {
    width: 64px;
    height: 64px;
    color: #D1D5DB;
    margin-bottom: 16px;
}

.calendar-empty-state h3 {
    font-size: 16px;
    color: #374151;
    margin: 0 0 8px 0;
}

.calendar-empty-state p {
    font-size: 14px;
    margin: 0;
}

/* Zero Calendar State */
.calendar-zero-events {
    background: linear-gradient(180deg, #ECFDF5 0%, #F9FAFB 100%);
}

.calendar-zero-events h3 {
    color: #059669;
    font-size: 20px;
    font-weight: 600;
}

.calendar-zero-events p {
    color: #6A7282;
}

.calendar-celebration-icon {
    margin-bottom: 16px;
    animation: celebrate 0.6s ease-out;
}

@keyframes celebrate {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.calendar-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6A7282;
    font-size: 14px;
    gap: 8px;
}

.calendar-list-empty-icon {
    font-size: 32px;
}

/* Loading State */
.calendar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6A7282;
}

.calendar-loading .loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #E5E7EB;
    border-top-color: #155DFC;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #FFFFFF;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: toastSlideIn 0.3s ease;
    max-width: 100%;
}

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

/* Mobile Navigation */
.calendar-mobile-nav {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border-bottom: 1px solid #E5E7EB;
    padding: 12px 16px;
    z-index: 100;
}

.calendar-mobile-back {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #155DFC;
    cursor: pointer;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet - Narrower left panel */
@media (max-width: 1200px) {
    .calendar-layout {
        grid-template-columns: 340px 4px 1fr;
    }
}

/* Tablet Portrait - Stack on selection */
@media (max-width: 1024px) {
    .calendar-layout {
        grid-template-columns: 1fr;
    }

    .calendar-resize-handle {
        display: none;
    }

    .calendar-list-panel {
        max-width: none;
    }

    .calendar-list-panel.hidden {
        display: none;
    }

    .calendar-detail-panel {
        display: none;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        padding-top: 60px;
    }

    .calendar-detail-panel.active {
        display: flex;
    }

    .calendar-mobile-nav {
        display: none;
    }

    .calendar-mobile-nav.active {
        display: block;
    }
}

/* Mobile - Full screen panels */
@media (max-width: 768px) {
    .calendar-page {
        height: calc(100vh - 56px);
    }

    .calendar-filters-section {
        padding: 12px;
    }

    .calendar-priority-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .calendar-priority-btn {
        flex-shrink: 0;
    }

    .calendar-item {
        padding: 12px;
    }

    .calendar-detail-panel {
        padding: 16px;
    }

    .calendar-header-card {
        padding: 16px;
    }

    .calendar-header-top {
        flex-direction: column;
        gap: 16px;
    }

    .calendar-action-btn {
        width: 100%;
        justify-content: center;
    }

    .calendar-tags-row {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .calendar-detail-tag {
        flex-shrink: 0;
    }

    .calendar-meta-grid {
        grid-template-columns: 1fr;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .calendar-status-filters {
        gap: 2px;
    }

    .calendar-status-btn {
        padding: 6px 10px;
    }

    .calendar-item-tags {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .calendar-tag {
        flex-shrink: 0;
    }
}

/* Loading spinner for buttons */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #E5E7EB;
    border-top-color: #155DFC;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
