/* ============================================================
   Company Calendar – Frontend Styles
   ============================================================ */

/* ── Reset / Base ─────────────────────────────────────────── */
.cc-wrap *,
.cc-wrap *::before,
.cc-wrap *::after {
    box-sizing: border-box;
}

.cc-wrap {
    --cc-primary:    #2563eb;
    --cc-danger:     #dc2626;
    --cc-success:    #16a34a;
    --cc-warning:    #d97706;
    --cc-bg:         #ffffff;
    --cc-surface:    #f8fafc;
    --cc-border:     #e2e8f0;
    --cc-text:       #1e293b;
    --cc-text-muted: #64748b;
    --cc-radius:     8px;
    --cc-shadow:     0 4px 24px rgba(0,0,0,.08);
    --cc-shadow-sm:  0 1px 4px rgba(0,0,0,.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--cc-text);
    position: relative;
}

/* ── Login notice ─────────────────────────────────────────── */
.cc-login-notice {
    text-align: center;
    padding: 60px 20px;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
}
.cc-login-notice p { font-size: 16px; margin-bottom: 16px; color: var(--cc-text-muted); }
.cc-notice {
    padding: 24px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--cc-radius);
    color: var(--cc-text);
}

/* ── Toolbar ──────────────────────────────────────────────── */
.cc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--cc-bg);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius) var(--cc-radius) 0 0;
    border-bottom: none;
}

/* ── Calendar Tabs ────────────────────────────────────────── */
.cc-calendar-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cc-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cc-text-muted);
    cursor: pointer;
    transition: all .15s ease;
    line-height: 1.3;
    white-space: nowrap;
}
.cc-tab:hover { border-color: var(--tab-color, var(--cc-primary)); color: var(--tab-color, var(--cc-primary)); background: #fff; }
.cc-tab.active {
    background: var(--tab-color, var(--cc-primary));
    border-color: var(--tab-color, var(--cc-primary));
    color: #fff;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--tab-color, var(--cc-primary)) 30%, transparent);
}
.cc-tab-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
    flex-shrink: 0;
}
.cc-tab.active .cc-tab-dot { background: rgba(255,255,255,.9); opacity: 1; }
.cc-tab-dept { font-size: 11px; opacity: .75; }

/* ── Toolbar right ────────────────────────────────────────── */
.cc-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cc-view-btns {
    display: flex;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: 6px;
    overflow: hidden;
}
.cc-view-btn {
    padding: 6px 14px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--cc-text-muted);
    cursor: pointer;
    transition: all .15s;
    border-right: 1px solid var(--cc-border);
}
.cc-view-btn:last-child { border-right: none; }
.cc-view-btn:hover { background: #fff; color: var(--cc-primary); }
.cc-view-btn.active { background: var(--cc-primary); color: #fff; }

/* ── Buttons ──────────────────────────────────────────────── */
.cc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
    text-decoration: none;
}
.cc-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.cc-btn-primary   { background: var(--cc-primary); color: #fff; border-color: var(--cc-primary); }
.cc-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.cc-btn-secondary { background: var(--cc-surface); color: var(--cc-text); border-color: var(--cc-border); }
.cc-btn-secondary:hover { background: #fff; border-color: #94a3b8; }
.cc-btn-danger    { background: var(--cc-danger); color: #fff; border-color: var(--cc-danger); }
.cc-btn-danger:hover { background: #b91c1c; }
.cc-btn-icon      { padding: 7px 10px; }
.cc-btn-sm        { padding: 5px 10px; font-size: 12px; }
.cc-btn-xs        { padding: 3px 8px; font-size: 11px; }

/* ── Calendar Container ───────────────────────────────────── */
.cc-calendar-container {
    background: var(--cc-bg);
    border: 1px solid var(--cc-border);
    border-radius: 0 0 var(--cc-radius) var(--cc-radius);
    padding: 16px;
    min-height: 600px;
}

/* FullCalendar overrides */
.cc-calendar-container .fc {
    font-family: inherit;
    font-size: 13px;
}
.cc-calendar-container .fc-toolbar-title { font-size: 17px; font-weight: 600; }
.cc-calendar-container .fc-button-primary {
    background: var(--cc-primary) !important;
    border-color: var(--cc-primary) !important;
}
.cc-calendar-container .fc-button-primary:hover {
    background: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
}
.cc-calendar-container .fc-button-active,
.cc-calendar-container .fc-button-primary:not(:disabled).fc-button-active {
    background: #1e40af !important;
    border-color: #1e40af !important;
}
.cc-calendar-container .fc-daygrid-day-number,
.cc-calendar-container .fc-col-header-cell-cushion { color: var(--cc-text); text-decoration: none; }
.cc-calendar-container .fc-daygrid-day.fc-day-today { background: #eff6ff; }
.cc-calendar-container .fc-event { cursor: pointer; }
.cc-calendar-container .fc-event-title { font-weight: 500; }
.cc-calendar-container .fc-toolbar { gap: 8px; }

/* ── Modal ────────────────────────────────────────────────── */
/*
 * IMPORTANT: use !important on alignment so WordPress themes cannot
 * accidentally override these and cause the modal to stick to the bottom.
 */
.cc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 99999;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px;
    animation: cc-fade-in .15s ease;
}
.cc-modal-overlay[hidden] { display: none !important; }

@keyframes cc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes cc-slide-up {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cc-modal {
    background: var(--cc-bg);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    animation: cc-slide-up .18s ease;
    /* Prevent theme flex rules from pushing modal to bottom/top */
    align-self: center !important;
    flex-shrink: 0;
}
.cc-modal-detail { max-width: 460px; }

.cc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--cc-border);
    gap: 12px;
}
.cc-modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.cc-modal-header-actions { display: flex; align-items: center; gap: 8px; }
.cc-modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--cc-text-muted); padding: 4px; border-radius: 6px;
    transition: all .15s;
}
.cc-modal-close:hover { background: var(--cc-surface); color: var(--cc-text); }
.cc-modal-close svg { width: 18px; height: 18px; display: block; }

.cc-modal-body { padding: 20px 24px; }
.cc-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--cc-border);
    gap: 8px;
}
.cc-modal-footer-right { display: flex; gap: 8px; }

/* ── Forms ────────────────────────────────────────────────── */
.cc-form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.cc-form-group:last-child { margin-bottom: 0; }
.cc-form-row { display: flex; gap: 14px; }
.cc-form-row .cc-form-group { flex: 1; min-width: 0; }
.cc-form-group label { font-size: 13px; font-weight: 500; color: var(--cc-text); }
.cc-required { color: var(--cc-danger); }

.cc-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--cc-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--cc-text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.cc-input:focus {
    outline: none;
    border-color: var(--cc-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.cc-textarea { resize: vertical; min-height: 80px; }

.cc-color-group { flex-direction: row; align-items: center; gap: 10px; }
.cc-color-input { width: 44px; height: 36px; padding: 2px; cursor: pointer; }

.cc-check-group { flex-direction: row; align-items: center; }
.cc-checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.cc-checkbox-box {
    width: 17px; height: 17px;
    border: 2px solid var(--cc-border);
    border-radius: 4px;
    display: inline-block;
    position: relative;
    transition: all .15s;
}
input:checked + .cc-checkbox-box {
    background: var(--cc-primary);
    border-color: var(--cc-primary);
}
input:checked + .cc-checkbox-box::after {
    content: '';
    position: absolute;
    left: 3px; top: 0;
    width: 6px; height: 10px;
    border: 2px solid #fff;
    border-top: none; border-left: none;
    transform: rotate(45deg);
}
input[type="checkbox"] { display: none; }

.cc-field-error { font-size: 12px; color: var(--cc-danger); min-height: 16px; }

/* ── Spinner ──────────────────────────────────────────────── */
.cc-spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cc-spin .6s linear infinite;
}
@keyframes cc-spin { to { transform: rotate(360deg); } }

/* ── Detail body ──────────────────────────────────────────── */
.cc-detail-body { padding: 16px 24px 24px; }
.cc-detail-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 12px;
    font-size: 13px;
}
.cc-detail-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--cc-text-muted); }
.cc-detail-label { font-weight: 500; color: var(--cc-text-muted); min-width: 100px; }
.cc-detail-value { color: var(--cc-text); }
.cc-detail-description { white-space: pre-wrap; font-size: 13px; color: var(--cc-text); margin: 8px 0 0; line-height: 1.6; }
.cc-detail-cal-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 99px;
    font-size: 12px; font-weight: 500; color: #fff;
}

/* ── Toast ────────────────────────────────────────────────── */
.cc-toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: #1e293b;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    z-index: 999999;
    animation: cc-slide-up .2s ease;
    max-width: 340px;
}
.cc-toast[hidden] { display: none; }
.cc-toast.cc-toast-error { background: #dc2626; }
.cc-toast.cc-toast-success { background: #16a34a; }

/* ── Print ────────────────────────────────────────────────── */
@media print {
    /* Hide all chrome except the calendar itself */
    .cc-toolbar,
    .cc-modal-overlay,
    .cc-toast,
    #wpadminbar,
    nav, header, footer,
    .site-header, .site-footer,
    .site-navigation,
    aside, .sidebar { display: none !important; }

    body  { background: #fff !important; margin: 0; }
    .cc-wrap { font-size: 10px; box-shadow: none; border: none; }

    .cc-calendar-container {
        border: none;
        padding: 4px 0 0;
    }

    /* ─ Header / toolbar ─ */
    .fc-toolbar-title     { font-size: 15px !important; font-weight: 700 !important; }
    .fc-button            { display: none !important; } /* hide nav buttons */

    /* ─ Table structure ─
       Remove any fixed row heights so rows expand to fit their content */
    .fc-daygrid-body,
    .fc-daygrid-body table       { height: auto !important; }
    .fc-daygrid-body tr          { height: auto !important; }
    .fc-daygrid-day              { height: auto !important; break-inside: avoid; }
    .fc-daygrid-day-frame        { min-height: 0 !important; height: auto !important; }

    /* ─ Event blocks ─
       Make sure every event is visible (JS sets dayMaxEvents: false before print),
       text wraps inside the block, and nothing is clipped. */
    .fc-daygrid-day-events       { overflow: visible !important; max-height: none !important; }
    .fc-daygrid-event-harness    { overflow: visible !important; }
    .fc-h-event                  { break-inside: avoid; margin-bottom: 2px !important; }
    .fc-event-title              {
        white-space: normal !important;
        word-break:  break-word !important;
        overflow:    visible !important;
        font-size:   9px !important;
        line-height: 1.3 !important;
    }
    .fc-event-time               { font-size: 8px !important; white-space: normal !important; }

    /* ─ Hide "+X more" links (JS already removed the limit) ─ */
    .fc-daygrid-more-link        { display: none !important; }

    /* ─ Page layout ─ */
    @page { margin: 1cm; size: A4 landscape; }
}

/* ── Mobile Day Panel (Samsung-style) ────────────────────── */
.cc-day-panel {
    border-top: 3px solid var(--cc-primary);
    background: var(--cc-bg);
    animation: cc-slide-up .2s ease;
}
.cc-day-panel[hidden] { display: none; }

.cc-day-panel-header {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    background: var(--cc-surface);
    border-bottom: 1px solid var(--cc-border);
}
.cc-day-panel-date {
    font-size: 13px; font-weight: 600; flex: 1; text-transform: capitalize;
    color: var(--cc-text);
}
.cc-day-panel-close {
    background: none; border: none; cursor: pointer;
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--cc-text-muted); transition: background .15s;
}
.cc-day-panel-close:hover { background: var(--cc-border); }
.cc-day-panel-close svg   { width: 16px; height: 16px; display: block; }

.cc-day-panel-body { max-height: 300px; overflow-y: auto; }

.cc-day-panel-events { list-style: none; padding: 6px; margin: 0; }
.cc-day-panel-event {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    cursor: pointer; transition: background .15s;
}
.cc-day-panel-event:hover,
.cc-day-panel-event:active { background: var(--cc-surface); }

.cc-day-panel-bar {
    width: 4px; min-height: 38px; border-radius: 3px; flex-shrink: 0;
}
.cc-day-panel-info  { flex: 1; min-width: 0; }
.cc-day-panel-title {
    font-size: 13px; font-weight: 600; color: var(--cc-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cc-day-panel-meta  { font-size: 11px; color: var(--cc-text-muted); margin-top: 2px; }
.cc-day-panel-empty {
    text-align: center; padding: 24px 16px;
    color: var(--cc-text-muted); font-size: 13px;
}
.cc-day-panel-add-row {
    padding: 10px 14px;
    border-top: 1px solid var(--cc-border);
}

/* Highlight the tapped day number */
.cc-day-selected .fc-daygrid-day-number {
    background: var(--cc-primary) !important;
    color: #fff !important;
    border-radius: 50%;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .cc-toolbar { flex-direction: column; align-items: stretch; }
    .cc-toolbar-right { justify-content: space-between; }
    .cc-form-row { flex-direction: column; }

    /* ── Modal: centered popup — reinforce with !important so no theme rule wins ── */
    .cc-modal-overlay {
        padding: 16px !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .cc-modal {
        max-height: 92vh !important;
        border-radius: 12px !important;
        overflow-y: auto !important;
        align-self: center !important;
        width: calc(100% - 0px) !important;  /* fill the padded area */
    }

    /* Slightly larger touch targets on event blocks */
    .cc-calendar-container .fc-daygrid-event { margin-bottom: 2px !important; }
    .cc-calendar-container .fc-event-title   { font-size: 11px !important; }
}
