/**
 * File: src/assets/css/clisyc-timeline.css
 * Styles for the Timeline Visualization Component
 * 
 * Supports 4 event types:
 * - Schedule (Open Hours) - light background showing resource availability
 * - Available Slots - solid green bookable times
 * - Booked - resource-colored appointments
 * - Blocked - red unavailable periods
 * 
 * ADDED: Resize handle styles
 * ADDED: Zoom toolbar styles
 */

/* ========================================
   MAIN CONTAINER
   ======================================== */
.clisyc-timeline-container {
    background: #ffffff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    overflow: visible;
    position: relative;
    min-height: 500px;
}

.clisyc-timeline-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 400px;
    position: relative;
    transition: none; /* Disable transitions during resize */
    margin-bottom: 20px; /* Space for the resize handle that sits below */
    padding-bottom: 2px; /* Small buffer */
}

.clisyc-timeline-wrapper.clisyc-timeline-resizing {
    user-select: none;
    cursor: ns-resize;
}

.clisyc-timeline-wrapper.clisyc-timeline-resizing * {
    pointer-events: none;
}

.clisyc-timeline-calendar-container {
    flex: 1;
    min-height: 300px;
    overflow: hidden;
}

/* In expanded mode, allow vertical overflow/scrolling */
.clisyc-timeline-expanded .clisyc-timeline-calendar-container {
    overflow: auto;
}

/* ========================================
   ZOOM TOOLBAR
   ======================================== */
.clisyc-timeline-zoom-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    background: linear-gradient(to bottom, #f9f9f9, #f0f0f1);
    border-bottom: 1px solid #c3c4c7;
    gap: 15px;
    flex-wrap: wrap;
}

.clisyc-timeline-zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.clisyc-timeline-zoom-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 12px;
    color: #1d2327;
    margin-right: 4px;
}

.clisyc-timeline-zoom-label .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #2271b1;
}

.clisyc-timeline-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #2271b1;
    border-radius: 3px;
    background: #fff;
    color: #2271b1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.clisyc-timeline-zoom-btn:hover:not(:disabled) {
    background: #2271b1;
    color: #fff;
}

.clisyc-timeline-zoom-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #a0a5aa;
    color: #a0a5aa;
}

.clisyc-timeline-zoom-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.clisyc-timeline-zoom-level {
    min-width: 36px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #1d2327;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    padding: 4px 8px;
}

.clisyc-timeline-zoom-reset {
    margin-left: 4px;
    border-color: #a0a5aa;
    color: #50575e;
}

.clisyc-timeline-zoom-reset:hover:not(:disabled) {
    background: #50575e;
    border-color: #50575e;
    color: #fff;
}

.clisyc-timeline-zoom-hint {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #646970;
}

.clisyc-timeline-zoom-hint .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* ========================================
   VIEW TOGGLE (Compact/Expanded)
   ======================================== */
.clisyc-timeline-view-toggle {
    display: flex;
    align-items: center;
}

.clisyc-timeline-compact-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    height: 28px;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    background: #fff;
    color: #50575e;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.clisyc-timeline-compact-btn:hover {
    background: #f0f0f1;
    border-color: #8c8f94;
}

.clisyc-timeline-compact-btn.is-active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.clisyc-timeline-compact-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.clisyc-timeline-toggle-label {
    white-space: nowrap;
}

/* ========================================
   COMPACT VIEW MODE - Fixed row heights
   ======================================== */
.clisyc-timeline-compact .fc-timeline-event {
    max-height: 22px !important;
    overflow: hidden;
}

.clisyc-timeline-compact .fc-timeline-event .fc-event-main {
    max-height: 22px;
    overflow: hidden;
}

.clisyc-timeline-compact .clisyc-timeline-event-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 20px;
    line-height: 20px;
}

.clisyc-timeline-compact .fc-event-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Expanded view - allow full text with scrolling */
.clisyc-timeline-expanded .fc-timeline-event {
    max-height: none;
    overflow: visible;
}

.clisyc-timeline-expanded .fc-timeline-event .fc-event-main {
    max-height: none;
    overflow: visible;
}

.clisyc-timeline-expanded .clisyc-timeline-event-content {
    white-space: normal;
    overflow: visible;
}

.clisyc-timeline-expanded .fc-event-title {
    white-space: normal;
}

/* Allow the timeline body to scroll in expanded mode */
.clisyc-timeline-expanded .fc-timeline-body {
    overflow-y: auto;
}

/* Custom event content wrapper */
.clisyc-timeline-event-content {
    padding: 1px 4px;
    cursor: pointer;
}

/* Tooltip styling for compact view */
.clisyc-timeline-compact .clisyc-timeline-event-content[title] {
    cursor: help;
}

/* ========================================
   RESIZE HANDLE
   ======================================== */
.clisyc-timeline-resize-handle {
    position: absolute;
    bottom: -18px; /* Position below the timeline to avoid overlapping FC's horizontal scrollbar */
    left: 0;
    right: 0;
    height: 14px;
    cursor: ns-resize;
    background: #f6f7f7;
    border: 1px solid #e5e5e5;
    border-top: none;
    border-radius: 0 0 4px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 10;
}

.clisyc-timeline-resize-handle:hover {
    background: linear-gradient(to bottom, rgba(34,113,177,0.05), rgba(34,113,177,0.1));
    border-top-color: #2271b1;
}

.clisyc-timeline-resize-grip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 0;
}

.clisyc-timeline-resize-grip span {
    width: 30px;
    height: 2px;
    background: #c3c4c7;
    border-radius: 1px;
    transition: background 0.15s ease;
}

.clisyc-timeline-resize-handle:hover .clisyc-timeline-resize-grip span {
    background: #2271b1;
}

/* Active resize state */
.clisyc-timeline-resizing .clisyc-timeline-resize-handle {
    background: rgba(34,113,177,0.1);
    border-top-color: #2271b1;
}

.clisyc-timeline-resizing .clisyc-timeline-resize-grip span {
    background: #2271b1;
}

/* ========================================
   TIMELINE LEGEND
   ======================================== */
.clisyc-timeline-legend {
    background: #f6f7f7;
    border-bottom: 1px solid #c3c4c7;
    padding: 12px 15px;
    font-size: 13px;
}

.clisyc-timeline-legend-header {
    margin-bottom: 8px;
}

.clisyc-timeline-legend-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #1d2327;
    font-size: 13px;
}

.clisyc-timeline-legend-title .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #2271b1;
}

.clisyc-timeline-legend-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.clisyc-timeline-legend-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.clisyc-timeline-legend-section-label {
    font-weight: 600;
    color: #50575e;
    font-size: 12px;
    white-space: nowrap;
}

.clisyc-timeline-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.clisyc-timeline-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: help;
}

.clisyc-timeline-legend-swatch {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    border-width: 2px;
    border-style: solid;
    flex-shrink: 0;
}

.clisyc-timeline-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.clisyc-timeline-legend-label {
    color: #1d2327;
    font-size: 12px;
    white-space: nowrap;
}

.clisyc-timeline-legend-item .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #646970;
}

.clisyc-timeline-legend-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    background: #2271b1;
    color: #fff;
    margin-left: 4px;
    font-weight: 500;
}

/* ========================================
   FULLCALENDAR OVERRIDES
   ======================================== */

.clisyc-timeline-container .fc {
    border: none;
}

/* Header Toolbar */
.clisyc-timeline-container .fc-header-toolbar {
    padding: 12px 15px;
    margin-bottom: 0 !important;
    background: #f6f7f7;
    border-bottom: 1px solid #c3c4c7;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clisyc-timeline-container .fc-toolbar-title {
    font-size: 1.2em !important;
    font-weight: 600;
    color: #1d2327;
}

/* Buttons */
.clisyc-timeline-container .fc-button {
    border-radius: 3px;
    text-transform: capitalize;
    font-weight: 500;
    font-size: 13px;
    padding: 4px 10px;
    height: 30px;
    line-height: 1;
}

.clisyc-timeline-container .fc-button-primary {
    background-color: #f6f7f7;
    border-color: #2271b1;
    color: #2271b1;
    box-shadow: none;
}

.clisyc-timeline-container .fc-button-primary:hover {
    background-color: #f0f0f1;
    border-color: #0a4b78;
    color: #0a4b78;
}

.clisyc-timeline-container .fc-button-primary:not(:disabled).fc-button-active,
.clisyc-timeline-container .fc-button-primary:not(:disabled):active {
    background-color: #2271b1;
    border-color: #2271b1;
    color: #fff;
    box-shadow: none;
}

/* Resource Area */
.fc-resource-area {
    background-color: #fff;
}

.fc-datagrid-cell-main {
    font-weight: 600;
    color: #1d2327;
    font-size: 13px;
    padding-left: 5px;
}

/* Resource Label Styling */
.clisyc-timeline-resource-label {
    display: flex;
    align-items: center;
    width: 100%;
    padding-right: 8px;
    gap: 8px;
}

.clisyc-timeline-resource-clickable {
    cursor: pointer;
    transition: background-color 0.15s ease;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 4px;
}

.clisyc-timeline-resource-clickable:hover {
    background-color: #f0f0f1;
}

.clisyc-timeline-resource-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.clisyc-timeline-resource-name {
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clisyc-timeline-resource-type-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: #e5e5e5;
    color: #50575e;
    flex-shrink: 0;
    text-transform: capitalize;
}

.clisyc-timeline-resource-edit-icon {
    font-size: 12px;
    width: 12px;
    height: 12px;
    color: #a0a5aa;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.clisyc-timeline-resource-clickable:hover .clisyc-timeline-resource-edit-icon {
    opacity: 1;
    color: #2271b1;
}

/* ========================================
   EVENT STYLING - 4 Types
   ======================================== */

/* Base event styling */
.fc-timeline-event {
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.fc-timeline-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10 !important;
}

.fc-event-title {
    font-weight: 500;
    padding: 1px 4px;
}

/* 1. SCHEDULE (Open Hours) - Light background */
.clisyc-timeline-schedule {
    opacity: 0.7;
}

/* 2. AVAILABLE SLOT (Bookable) - Solid green */
.clisyc-timeline-slot {
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.clisyc-timeline-slot .fc-event-title {
    font-weight: 600;
}

/* 3. BOOKED - Resource colored */
.clisyc-timeline-booked {
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.clisyc-timeline-booked .fc-event-title {
    font-weight: 600;
}

/* 4. BLOCKED - Red */
.clisyc-timeline-blocked {
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* 5. ALWAYS AVAILABLE - Light blue */
.clisyc-timeline-always-available {
    opacity: 0.6;
    border-style: dashed !important;
}

/* Fix z-index issues with WP Admin Menu */
.fc-view-harness {
    z-index: 0;
}

/* ========================================
   LOADING STATE
   ======================================== */
.clisyc-timeline-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    background: #fff;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
}

.clisyc-timeline-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: clisyc-timeline-spin 0.8s linear infinite;
    margin-bottom: 15px;
}

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

/* ========================================
   STATUS BADGES (for modals)
   ======================================== */
.clisyc-timeline-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.clisyc-timeline-status-schedule  { background-color: #e0f2fe; color: #0369a1; }
.clisyc-timeline-status-available { background-color: #d1fae5; color: #065f46; }
.clisyc-timeline-status-booked    { background-color: #fffbc0; color: #5c4d0b; } /* Light yellow */
.clisyc-timeline-status-blocked   { background-color: #fee2e2; color: #991b1b; }

/* ========================================
   HEIGHT INPUT STYLING (Admin Form)
   ======================================== */
.clisyc-timeline-height-input {
    display: flex;
    align-items: center;
    gap: 6px;
}

.clisyc-timeline-height-input input[type="number"] {
    width: 100px;
}

.clisyc-timeline-height-input .units {
    color: #646970;
    font-size: 13px;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 782px) {
    .clisyc-timeline-legend-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .clisyc-timeline-legend-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .clisyc-timeline-container .fc-header-toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .clisyc-timeline-zoom-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .clisyc-timeline-zoom-hint {
        display: none;
    }
    
    .clisyc-timeline-toggle-label {
        display: none;
    }
}

@media (max-width: 600px) {
    .clisyc-timeline-resource-type-badge {
        display: none;
    }
    
    .clisyc-timeline-zoom-label span:not(.dashicons) {
        display: none;
    }
}

/**
 * Additional CSS for Timeline Event Content
 * Add these styles to: src/assets/css/clisyc-timeline.css
 * 
 * IMPROVED: Expanded view with dimension color dots and details
 */

/* ==========================================================================
   Expanded Event Content Styles
   ========================================================================== */

/* Event content wrapper */
.clisyc-timeline-event-content {
    padding: 2px 4px;
    overflow: hidden;
    line-height: 1.3;
}

.clisyc-timeline-event-expanded {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Event header with title and time */
.clisyc-timeline-event-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.clisyc-timeline-event-header .fc-event-title {
    font-weight: 600;
    font-size: 11px;
}

.clisyc-timeline-event-time {
    font-size: 10px;
    opacity: 0.85;
    white-space: nowrap;
}

/* Dimensions container */
.clisyc-timeline-event-dimensions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 2px;
}

/* Individual dimension item with color dot */
.clisyc-timeline-dimension-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    line-height: 1.2;
}

.clisyc-timeline-dimension-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.clisyc-timeline-dimension-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* ==========================================================================
   Compact vs Expanded Mode Adjustments
   ========================================================================== */

/* Compact mode - minimal height */
.clisyc-timeline-compact .fc-timeline-event {
    min-height: 22px;
}

.clisyc-timeline-compact .fc-event-main {
    padding: 1px 3px;
}

.clisyc-timeline-compact .clisyc-timeline-event-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Expanded mode - taller events to show details */
.clisyc-timeline-expanded .fc-timeline-event {
    min-height: 44px;
}

.clisyc-timeline-expanded .fc-event-main {
    padding: 3px 5px;
}

.clisyc-timeline-expanded .clisyc-timeline-event-content {
    white-space: normal;
}

/* Make slot events taller in expanded mode */
.clisyc-timeline-expanded .clisyc-timeline-slot {
    min-height: 50px;
}

/* ==========================================================================
   Slot-specific Styles in Expanded Mode
   ========================================================================== */

/* Available slots - emphasize the dimensions */
.clisyc-timeline-expanded .clisyc-timeline-slot .clisyc-timeline-event-dimensions {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    margin-top: 3px;
}

/* Booked events - show client info prominently */
.clisyc-timeline-expanded .clisyc-timeline-booked .clisyc-timeline-event-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 2px;
    margin-bottom: 2px;
}

/* ==========================================================================
   Improved Tooltip Styles (native title attribute)
   ========================================================================== */

/* For better tooltips, consider using a tooltip library like Tippy.js
   The native title attribute will show the multiline tooltip text
   with line breaks preserved on most browsers */

/* If you want custom styled tooltips in the future, add a tooltip container */
.clisyc-timeline-tooltip {
    position: absolute;
    z-index: 10000;
    background: #1e293b;
    color: #f1f5f9;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    max-width: 280px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    white-space: pre-line;
}

.clisyc-timeline-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #1e293b;
}

/* ==========================================================================
   Resource Row Height Adjustments
   ========================================================================== */

/* Ensure resource rows have enough height for expanded content */
.clisyc-timeline-expanded .fc-timeline-lane {
    min-height: 55px;
}

.clisyc-timeline-compact .fc-timeline-lane {
    min-height: 28px;
}

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

@media (max-width: 1200px) {
    .clisyc-timeline-dimension-name {
        max-width: 70px;
    }
}

@media (max-width: 900px) {
    .clisyc-timeline-event-dimensions {
        display: none;
    }
    
    .clisyc-timeline-event-time {
        display: none;
    }
}

/* ==========================================================================
   Animation for View Toggle
   ========================================================================== */

.clisyc-timeline-wrapper {
    transition: none; /* Prevent layout shift during toggle */
}

.fc-timeline-event {
    transition: min-height 0.2s ease;
}