/* ═══════════════════════════════════════════════════════════════
   StaffHub — Company Calendar Styles (Mobile-Optimized)
   ═══════════════════════════════════════════════════════════════ */

/* ── Controls Bar ──────────────────────────────────────────── */
.cal-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.cal-nav-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cal-nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 0.2s;
}
.cal-nav-btn:hover { background: #e8f0fe; color: #1a73e8; border-color: #1a73e8; }
.cal-nav-btn:active { background: #dbeafe; }

.cal-period-label {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    min-width: 200px;
    text-align: center;
}

.cal-today-btn {
    padding: 0.5rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
}
.cal-today-btn:hover { background: #e8f0fe; color: #1a73e8; border-color: #1a73e8; }

.cal-view-tabs {
    display: flex;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.cal-view-tab {
    padding: 0.5rem 0.875rem;
    border: none;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border-right: 1px solid #e2e8f0;
    min-height: 40px;
    display: flex;
    align-items: center;
}
.cal-view-tab:last-child { border-right: none; }
.cal-view-tab.active { background: #1a73e8; color: #fff; font-weight: 600; }
.cal-view-tab:hover:not(.active) { background: #e8f0fe; color: #1a73e8; }

.cal-actions-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cal-filter-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.cal-filter-btn:hover, .cal-filter-btn.active { background: #e8f0fe; color: #1a73e8; border-color: #1a73e8; }

.cal-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 40px;
}
.cal-add-btn:hover { background: #1557b0; }
.cal-add-btn:active { background: #1146a0; }

/* ── Filter Panel ──────────────────────────────────────────── */
.cal-filter-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.cal-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 150px;
}

.cal-filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cal-filter-select,
.cal-filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem; /* 16px prevents iOS zoom */
    background: #fff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s;
    min-height: 40px;
}
.cal-filter-select:focus, .cal-filter-input:focus { border-color: #1a73e8; }

/* ═══════════════════════════════════════════════════════════════
   MONTH VIEW
   — Outer wrapper handles all scrolling (horizontal + vertical).
   — Inner grid has a fixed min-width so 7 columns never collapse.
   — Row heights are FIXED so cells never stretch due to content.
   ═══════════════════════════════════════════════════════════════ */

/* Scrollable outer shell */
.cal-month-scroll-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    max-height: calc(100vh - 220px);
}

.cal-month-grid {
    background: #fff;
    min-width: 420px;
    width: 100%;
}

.cal-month-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    /* Sticks in place while scrolling vertically */
    position: sticky;
    top: 0;
    z-index: 2;
}

.cal-month-dow {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cal-month-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* FIXED row height — content never pushes rows taller */
    grid-auto-rows: 110px;
}

/* Day cell — fixed height, clips overflow */
.cal-day-cell {
    border-right: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.375rem;
    height: 110px;        /* must match grid-auto-rows */
    overflow: hidden;     /* content never stretches the cell */
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    box-sizing: border-box;
}
.cal-day-cell:hover { background: #f8fafc; }
.cal-day-cell:active { background: #eff6ff; }
.cal-day-cell.other-month { background: #fafafa; }
.cal-day-cell.other-month .cal-day-num { color: #cbd5e1; }
.cal-day-cell.today { background: #eff6ff; }
.cal-day-cell.today .cal-day-num {
    background: #1a73e8;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-day-cell:last-child { border-right: none; }

.cal-day-num {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.25rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cal-day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;   /* clips pills beyond the cell boundary */
}

/* Pill — single line, always truncates with ellipsis */
.cal-event-pill {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: opacity 0.15s;
    color: #fff;
    max-width: 100%;
    box-sizing: border-box;
    line-height: 1.5;
}
.cal-event-pill:hover { opacity: 0.85; }

.cal-more-link {
    font-size: 0.6875rem;
    color: #1a73e8;
    font-weight: 600;
    cursor: pointer;
    padding: 1px 6px;
    white-space: nowrap;
}
.cal-more-link:hover { text-decoration: underline; }

/* ── Week View ─────────────────────────────────────────────── */
.cal-week-grid {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.cal-week-header {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    min-width: 420px;
}

.cal-week-time-gutter { border-right: 1px solid #e2e8f0; }

.cal-week-day-header {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-right: 1px solid #f1f5f9;
}

.cal-week-day-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cal-week-day-num {
    font-size: 1.375rem;
    font-weight: 700;
    color: #0f172a;
    margin-top: 0.25rem;
}

.cal-week-day-header.today .cal-week-day-num {
    background: #1a73e8;
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.25rem auto 0;
}

.cal-week-events-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    min-height: 80px;
    border-top: 1px solid #f1f5f9;
    min-width: 420px;
}

.cal-week-gutter-cell {
    border-right: 1px solid #e2e8f0;
    padding: 0.5rem 0.375rem;
    font-size: 0.6875rem;
    color: #94a3b8;
    text-align: right;
}

.cal-week-day-cell {
    border-right: 1px solid #f1f5f9;
    padding: 0.375rem;
    min-height: 80px;
    overflow: hidden;
}

.cal-week-event-block {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 6px;
    margin-bottom: 3px;
    cursor: pointer;
    color: #fff;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-week-event-block:hover { opacity: 0.85; }

/* ── List View ─────────────────────────────────────────────── */
.cal-list-view {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.cal-list-date-group { border-bottom: 1px solid #e2e8f0; }
.cal-list-date-group:last-child { border-bottom: none; }

.cal-list-date-header {
    background: #f8fafc;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.cal-list-date-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: #0f172a;
}

.cal-list-date-dow {
    font-size: 0.8125rem;
    color: #64748b;
}

.cal-list-event-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 56px;
}
.cal-list-event-row:last-child { border-bottom: none; }
.cal-list-event-row:hover { background: #f8fafc; }
.cal-list-event-row:active { background: #eff6ff; }

.cal-list-event-color {
    width: 4px;
    min-height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 2px;
}

.cal-list-event-info { flex: 1; min-width: 0; }
.cal-list-event-title {
    font-weight: 600;
    color: #0f172a;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-list-event-meta {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.25rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.cal-list-event-type-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-top: 0.375rem;
    display: inline-block;
}

/* ── Empty State ───────────────────────────────────────────── */
.cal-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #94a3b8;
}
.cal-empty-state i { font-size: 3rem; margin-bottom: 1rem; }
.cal-empty-state p { font-size: 0.9375rem; }

/* ── Event Detail in Modal ─────────────────────────────────── */
.cal-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    background: #f8fafc;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}
.cal-detail-meta-item { display: flex; flex-direction: column; gap: 0.2rem; }
.cal-detail-meta-label { font-size: 0.6875rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.cal-detail-meta-value { font-size: 0.9375rem; font-weight: 600; color: #0f172a; word-break: break-word; }

.cal-attendees-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.cal-attendee-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: #e8f0fe;
    color: #1a73e8;
    border-radius: 9999px;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    min-height: 32px;
}
.cal-attendee-chip button {
    background: none;
    border: none;
    color: #1a73e8;
    cursor: pointer;
    padding: 4px;
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.6;
    min-width: 24px;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-attendee-chip button:hover { opacity: 1; }

/* Attendee search */
.cal-attendee-search-wrapper { position: relative; }
.cal-attendee-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 200;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.cal-attendee-result-item {
    padding: 0.75rem 0.875rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #0f172a;
    transition: background 0.15s;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.cal-attendee-result-item:hover { background: #f0f9ff; }
.cal-attendee-result-item:active { background: #dbeafe; }
.cal-attendees-selected { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; min-height: 32px; }

/* Color input */
.cal-color-input {
    width: 48px;
    height: 40px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
}

/* ── Event Type Colors ─────────────────────────────────────── */
.cal-type-training      { background: #7c3aed; }
.cal-type-company_event { background: #059669; }
.cal-type-meeting       { background: #2563eb; }
.cal-type-deadline      { background: #dc2626; }
.cal-type-other         { background: #64748b; }

/* ── Day Modal Event List ──────────────────────────────────── */
.cal-day-event-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 56px;
}
.cal-day-event-item:hover { border-color: #1a73e8; background: #f0f7ff; }
.cal-day-event-item:active { background: #dbeafe; }
.cal-day-event-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.cal-day-event-body { flex: 1; min-width: 0; }
.cal-day-event-title { font-weight: 600; color: #0f172a; font-size: 0.9375rem; }
.cal-day-event-sub { font-size: 0.8125rem; color: #64748b; margin-top: 2px; }

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — Tablet (≤ 900px)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .cal-controls {
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    .cal-period-label {
        min-width: 160px;
        font-size: 1rem;
    }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — Mobile (≤ 768px)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .cal-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.625rem;
        padding: 0.75rem;
    }
    .cal-nav-group {
        justify-content: space-between;
        width: 100%;
    }
    .cal-period-label {
        min-width: unset;
        text-align: center;
        flex: 1;
        font-size: 1rem;
    }
    .cal-view-tabs { width: 100%; }
    .cal-view-tab {
        flex: 1;
        justify-content: center;
        text-align: center;
    }
    .cal-actions-group {
        width: 100%;
        justify-content: space-between;
    }
    .cal-add-btn { flex: 1; }

    .cal-month-scroll-wrapper {
        max-height: calc(100vh - 280px);
        border-radius: 10px;
    }

    .cal-month-grid  { min-width: 420px; }
    .cal-month-body  { grid-auto-rows: 76px; }
    .cal-day-cell    { height: 76px; padding: 0.25rem; }

    .cal-month-dow {
        padding: 0.5rem 0.25rem;
        font-size: 0.625rem;
    }

    .cal-event-pill {
        font-size: 0.5625rem;
        padding: 1px 4px;
        border-radius: 3px;
        line-height: 1.45;
    }

    .cal-more-link {
        font-size: 0.5625rem;
        padding: 0 4px;
        line-height: 1.4;
    }

    .cal-day-num {
        width: 22px;
        height: 22px;
        font-size: 0.6875rem;
        margin-bottom: 2px;
    }
    .cal-day-cell.today .cal-day-num {
        width: 22px;
        height: 22px;
    }

    .cal-week-header,
    .cal-week-events-row { min-width: 420px; }

    .cal-list-event-row  { padding: 0.75rem 1rem; gap: 0.75rem; }

    .cal-filter-panel {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    .cal-filter-group    { min-width: 0; width: 100%; }

    .cal-detail-meta {
        grid-template-columns: 1fr 1fr;
        padding: 0.75rem;
    }

    .cal-empty-state     { padding: 2rem 1rem; }
    .cal-empty-state i   { font-size: 2rem; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — Small phone (≤ 480px)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .cal-month-scroll-wrapper { max-height: calc(100vh - 300px); }
    .cal-month-body  { grid-auto-rows: 68px; }
    .cal-day-cell    { height: 68px; }

    .cal-event-pill  { font-size: 0.5rem; padding: 1px 3px; }

    .cal-detail-meta { grid-template-columns: 1fr; }

    .cal-list-date-header { padding: 0.625rem 0.75rem; }
    .cal-list-event-row   { padding: 0.625rem 0.75rem; }

    .cal-attendee-chip {
        font-size: 0.75rem;
        padding: 0.25rem 0.625rem;
    }
}