/* ============================================
   AICC Calendar Styles
   Version: 1.0
   ============================================ */

/* ============================================
   Calendar Container
   ============================================ */

.calendar-container-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 600px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}

/* ============================================
   Calendar Header
   ============================================ */

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

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

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

.calendar-title i {
    color: #FF6B00;
}

.calendar-nav-btns {
    display: flex;
    gap: 4px;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-icon-sm:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #ccc;
}

.calendar-current-month {
    font-size: 15px;
    font-weight: 500;
    color: #333;
}

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

.calendar-view-toggle {
    display: flex;
    background: #f0f0f0;
    border-radius: 6px;
    padding: 2px;
}

.calendar-view-toggle .view-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.calendar-view-toggle .view-btn:hover {
    color: #333;
}

.calendar-view-toggle .view-btn.active {
    background: #FF6B00;
    color: #fff;
}

/* ============================================
   Connection Status Bar
   ============================================ */

.calendar-connection-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-label {
    color: #666;
}

.connection-provider {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #999;
}

.connection-provider.connected {
    color: #4CAF50;
}

.connection-provider i {
    font-size: 14px;
}

/* ============================================
   Calendar Body (Sidebar + Main)
   ============================================ */

.calendar-body {
    display: flex;
    flex: 1;
    min-height: 0; /* Important for flex child to shrink */
    overflow: hidden;
}

/* ============================================
   Calendar Sidebar
   ============================================ */

.calendar-sidebar {
    width: 240px;
    background: #fafafa;
    border-right: 1px solid #e0e0e0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

/* Mini Calendar */
.mini-calendar {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e0e0e0;
}

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

.mini-calendar-title {
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

.mini-calendar-nav {
    display: flex;
    gap: 4px;
}

.mini-calendar-nav button {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    font-size: 10px;
}

.mini-calendar-nav button:hover {
    background: #f0f0f0;
    color: #333;
}

.mini-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-calendar-day-header {
    text-align: center;
    font-size: 10px;
    color: #999;
    padding: 4px 0;
}

.mini-calendar-day {
    text-align: center;
    font-size: 11px;
    color: #666;
    padding: 4px 0;
    border-radius: 4px;
    cursor: pointer;
}

.mini-calendar-day:hover {
    background: #f0f0f0;
    color: #333;
}

.mini-calendar-day.other-month {
    color: #ccc;
}

.mini-calendar-day.today {
    background: #FF6B00;
    color: #fff;
    font-weight: 600;
}

.mini-calendar-day.selected {
    background: #2196F3;
    color: #fff;
}

.mini-calendar-day.has-events::after {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    background: #4CAF50;
    border-radius: 50%;
    margin: 2px auto 0;
}

/* Calendars List */
.calendars-list {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e0e0e0;
}

.calendars-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendars-list-title {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.calendars-list-title i {
    color: #FF6B00;
}

.btn-icon-xs {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
    font-size: 10px;
    margin-bottom: 8px;
}

.btn-icon-xs:hover {
    background: #f0f0f0;
    color: #333;
}

.calendar-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
}

.calendar-checkbox input[type="checkbox"] {
    display: none;
}

.calendar-checkbox .calendar-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.calendar-checkbox input[type="checkbox"]:not(:checked) + .calendar-color {
    opacity: 0.3;
}

.calendar-checkbox .calendar-name {
    font-size: 12px;
    color: #333;
}

.no-shared-calendars {
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin: 0;
}

.calendar-members {
    margin-left: auto;
    font-size: 10px;
    color: #999;
}

/* Shared Calendar Row */
.shared-calendar-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.shared-calendar-row .calendar-checkbox {
    flex: 1;
}

.btn-sync-workspace {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-sync-workspace:hover {
    background: #e3f2fd;
    color: #2196F3;
}

.btn-delete-calendar {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-delete-calendar:hover {
    background: #ffebee;
    color: #f44336;
}

/* Color Picker Grid */
.color-picker-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    cursor: pointer;
}

.color-option input[type="radio"] {
    display: none;
}

.color-option .color-swatch {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: all 0.15s ease;
}

.color-option input[type="radio"]:checked + .color-swatch {
    border-color: #333;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

.color-option:hover .color-swatch {
    transform: scale(1.1);
}

/* AI Scheduling Section */
.calendar-ai-section {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e0e0e0;
}

.ai-schedule-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-schedule-input textarea {
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    font-size: 12px;
    resize: none;
}

.ai-schedule-input textarea:focus {
    border-color: #FF6B00;
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.2);
}

.ai-schedule-input button {
    align-self: flex-end;
}

/* ============================================
   Main Calendar Grid
   ============================================ */

.calendar-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex child to shrink */
    overflow: hidden;
    background: #fff;
}

.calendar-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex child to shrink */
    overflow: auto;
    padding: 12px;
    background: #fff;
}

.calendar-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #666;
    font-size: 14px;
    background: #fff;
    border-radius: 8px;
}

/* Week Header */
.calendar-week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 8px 8px 0 0;
}

.calendar-week-day {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    padding: 8px 0;
    background: #f5f5f5;
}

.calendar-week-day:first-child {
    border-radius: 8px 0 0 0;
}

.calendar-week-day:last-child {
    border-radius: 0 8px 0 0;
}

/* Month Grid */
.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, minmax(70px, 1fr));
    gap: 1px;
    flex: 1;
    min-height: 0; /* Important for flex child to shrink */
    background: #ddd;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.calendar-day-cell {
    background: #fff;
    padding: 4px;
    min-height: 0; /* Allow cells to shrink */
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background 0.15s ease;
    overflow: hidden;
}

.calendar-day-cell:hover {
    background: #f0f0f0;
}

.calendar-day-cell.other-month {
    background: #f8f8f8;
}

.calendar-day-cell.other-month .day-number {
    color: #bbb;
}

.calendar-day-cell.today {
    background: #fff8f0;
}

.calendar-day-cell.today .day-number {
    background: #FF6B00;
    color: #fff;
}

.calendar-day-cell.selected {
    background: #e3f2fd;
    outline: 2px solid #2196F3;
    outline-offset: -2px;
}

.day-number {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 4px;
}

.day-events {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.day-event {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    cursor: pointer;
}

.day-event.google {
    background: #4285F4;
}

.day-event.microsoft {
    background: #00A4EF;
}

.day-event.local {
    background: #FF6B00;
}

.day-event.roadmap {
    background: #9C27B0;
}

.day-event:hover {
    filter: brightness(0.9);
}

.day-more-events {
    font-size: 10px;
    color: #666;
    padding: 2px 4px;
}

/* ============================================
   Week View
   ============================================ */

.calendar-week-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    flex: 1;
    overflow: auto;
    background: #fff;
    border-radius: 8px;
}

.calendar-time-col {
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}

.calendar-time-slot {
    height: 48px;
    font-size: 10px;
    color: #666;
    text-align: right;
    padding-right: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.calendar-day-col {
    border-left: 1px solid #e0e0e0;
    position: relative;
    background: #fff;
}

.calendar-day-col-header {
    padding: 8px;
    text-align: center;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 1;
}

.calendar-day-col-header .day-name {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
}

.calendar-day-col-header .day-number {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin: 0 auto;
}

.calendar-day-col-header.today .day-number {
    background: #FF6B00;
    color: #fff;
}

.calendar-hour-slot {
    height: 48px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.calendar-hour-slot:hover {
    background: rgba(255, 107, 0, 0.08);
}

.week-event {
    position: absolute;
    left: 2px;
    right: 2px;
    background: #FF6B00;
    border-radius: 4px;
    padding: 4px;
    font-size: 11px;
    color: #fff;
    overflow: hidden;
    cursor: pointer;
    z-index: 1;
}

.week-event:hover {
    filter: brightness(1.1);
}

.week-event-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-event-time {
    font-size: 10px;
    opacity: 0.8;
}

/* ============================================
   Day View
   ============================================ */

.calendar-day-grid {
    display: grid;
    grid-template-columns: 60px 1fr;
    flex: 1;
    overflow: auto;
    background: #fff;
    border-radius: 8px;
}

.calendar-day-header {
    grid-column: span 2;
    padding: 16px;
    text-align: center;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.calendar-day-header .day-full {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.calendar-day-header .day-date {
    font-size: 14px;
    color: #666;
}

/* ============================================
   Event Modal
   ============================================ */

.calendar-event-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.calendar-event-modal.open {
    opacity: 1;
    visibility: visible;
}

.calendar-event-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.calendar-event-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.calendar-event-modal-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-event-modal-header h5 i {
    color: #FF6B00;
}

.calendar-event-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
}

.calendar-event-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.calendar-event-modal-body {
    padding: 20px;
}

.calendar-event-form-group {
    margin-bottom: 16px;
}

.calendar-event-form-group label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-event-form-group input,
.calendar-event-form-group textarea,
.calendar-event-form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    font-size: 14px;
}

.calendar-event-form-group input:focus,
.calendar-event-form-group textarea:focus,
.calendar-event-form-group select:focus {
    border-color: #FF6B00;
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.2);
}

.calendar-event-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.calendar-event-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-event-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #FF6B00;
}

.calendar-event-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
}

/* ============================================
   Connections Modal
   ============================================ */

.connections-modal-content {
    max-width: 600px;
}

.connection-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #e0e0e0;
}

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

.connection-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 20px;
}

.connection-card-icon.google {
    background: rgba(66, 133, 244, 0.2);
    color: #4285F4;
}

.connection-card-icon.microsoft {
    background: rgba(0, 164, 239, 0.2);
    color: #00A4EF;
}

.connection-card-info h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.connection-card-info p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #888;
}

.connection-card-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.connection-card-status.connected {
    color: #4CAF50;
}

.connection-card-status.not-connected {
    color: #888;
}

.connection-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.connection-card-actions .btn {
    white-space: nowrap;
}

/* ============================================
   General Modal Overlay (Shared Calendar, etc.)
   ============================================ */

.calendar-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    backdrop-filter: blur(2px);
}

.calendar-modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calendar-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.calendar-modal-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.calendar-modal-header .btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-modal-header .btn-close:hover {
    background: #f0f0f0;
    color: #333;
}

.calendar-modal-body {
    padding: 20px;
}

.calendar-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

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

@media (max-width: 1024px) {
    .calendar-sidebar {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .calendar-body {
        flex-direction: column;
    }

    .calendar-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .calendar-sidebar > div {
        flex: 1;
        min-width: 200px;
    }

    .mini-calendar {
        display: none;
    }

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

    .calendar-header-left,
    .calendar-header-right {
        width: 100%;
        justify-content: center;
    }
}
