/* ── 홈 대시보드 위젯 ── */

/* 1. 개인 봉사 목표 위젯 */
.home-service-widget {
    margin: var(--space-xs) var(--space-xs) 0;
    padding: var(--space-md);
    /* Internal padding also refined */
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.home-service-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--blue));
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--space-sm);
}

.widget-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.widget-period {
    font-size: 12px;
    color: var(--text-muted);
}

.progress-container {
    margin-bottom: 12px;
}

.progress-bar-bg {
    height: 12px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 6px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-main {
    font-size: 24px;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--accent);
}

.stat-goal {
    font-size: 14px;
    color: var(--text-muted);
}

.stat-percent {
    font-size: 16px;
    font-weight: 700;
    color: var(--green);
}

/* 2. 다가오는 일정 리스트 */
.schedule-list-container {
    margin: var(--space-xs) var(--space-xs) 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.home-next-schedule {
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border);
}

.home-next-schedule:last-child {
    border-bottom: none;
}

.home-next-schedule:active {
    background: var(--bg);
}

.schedule-icon {
    font-size: 18px;
    width: 36px;
    height: 36px;
    background: var(--green-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.schedule-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--green);
    margin-bottom: 2px;
}

.schedule-subject {
    font-size: 18px;
    /* 14px -> 16px -> 18px */
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.schedule-time {
    font-size: 15px;
    /* 11px -> 13px -> 15px */
    font-weight: 500;
    color: var(--text-muted);
}

.schedule-dday {
    background: var(--green);
    color: #fff;
    padding: 4px 10px;
    /* 3px 8px -> 4px 10px */
    border-radius: 20px;
    font-size: 12px;
    /* 10px -> 12px */
    font-weight: 700;
    font-family: var(--font-mono);
    flex-shrink: 0;
}

/* 기존 섹션 라벨 간격 조정 */
.tab-section>.section-label:first-child {
    padding-top: 8px;
}

/* 3. 봉사 일정 판 (신규 - 컴팩트 버전) */
.home-plan-widget {
    margin: var(--space-xs) var(--space-xs) 0;
    padding: var(--space-md);
    min-height: 110px;
    height: auto;
    /* Unified Height */
    background: linear-gradient(135deg, var(--accent) 0%, #2c5282 100%);
    border-radius: 20px;
    color: #fff;
    box-shadow: 0 4px 15px rgba(26, 58, 92, 0.1);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-sm);
}

.home-plan-widget::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.plan-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-label {
    display: block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1px;
    opacity: 0.7;
    margin-bottom: 2px;
}

.plan-title {
    font-size: 18px;
    font-weight: 700;
}

.plan-date {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.plan-body {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    width: 100%;
}

.plan-empty-text {
    font-size: 16px;
    font-weight: 700;
    opacity: 0.98;
    line-height: 1.5;
    white-space: pre-wrap;
    width: 100%;
}

.plan-setup-btn {
    padding: 6px 12px;
    background: #fff;
    color: var(--accent);
    border: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    transition: transform 0.1s, opacity 0.2s;
}

.plan-setup-btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

/* 0. 관리자 전용 승인 대기 알림 */
.home-admin-alert {
    margin: var(--space-xs) var(--space-xs) 0;
    padding: var(--space-md);
    background: #fff8f8;
    border-radius: 16px;
    border: 1px solid var(--red-faint);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.05);
    animation: fadeInDown 0.4s ease-out;
}

.home-admin-alert:active {
    background: #fdf0ef;
    transform: translateY(1px);
}

.alert-icon {
    width: 40px;
    height: 40px;
    background: var(--red-faint);
    color: var(--red);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.alert-body {
    flex: 1;
}

.alert-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 2px;
}

.alert-sub {
    font-size: 12px;
    color: #c0392b99;
    font-weight: 500;
}

.alert-arrow {
    color: var(--red);
    opacity: 0.5;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── [SECURITY] 시스템 다크 모드 강제 고대비 스타일 ── */
@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) .home-service-widget,
    :root:not([data-theme="light"]) .schedule-list-container,
    :root:not([data-theme="light"]) .home-admin-alert {
        background-color: #1e1e1e !important;
        border-color: #333333 !important;
    }

    :root:not([data-theme="light"]) .widget-title,
    :root:not([data-theme="light"]) .schedule-subject,
    :root:not([data-theme="light"]) .alert-title {
        color: #ffffff !important;
    }

    :root:not([data-theme="light"]) .widget-period,
    :root:not([data-theme="light"]) .stat-goal,
    :root:not([data-theme="light"]) .schedule-time,
    :root:not([data-theme="light"]) .alert-sub {
        color: #aaaaaa !important;
    }

    :root:not([data-theme="light"]) .home-next-schedule:active,
    :root:not([data-theme="light"]) .home-admin-alert:active {
        background-color: #252525 !important;
    }

    :root:not([data-theme="light"]) .progress-bar-bg {
        background: #252525 !important;
    }

    :root:not([data-theme="light"]) .home-admin-alert {
        background-color: #221515 !important;
        /* 약간 어두운 붉은톤 대응 */
        border-color: #4c2b2b !important;
    }

    :root:not([data-theme="light"]) .alert-icon {
        background-color: #3d1a1a !important;
    }
}

/* 4. 이번 주 집회 정보 위젯 */
.home-meeting-widget {
    margin: var(--space-xs) var(--space-xs) 0;
    padding: var(--space-sm) var(--space-md);
    height: 110px;
    /* Unified Height */
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.meeting-header {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.meeting-header::before {
    content: '';
    display: block;
    width: 4px;
    height: 16px;
    background: var(--blue);
    border-radius: 2px;
}

.meeting-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.meeting-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.meeting-item {
    padding: 8px 10px;
    background: var(--bg-faint);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.5px;
}

.meeting-day {
    font-size: 11px;
    font-weight: 800;
    color: var(--blue);
    opacity: 0.8;
}

.meeting-time {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.meeting-type {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .home-meeting-widget {
        background: #1e1e1e !important;
    }

    :root:not([data-theme="light"]) .meeting-item {
        background: #252525 !important;
    }

    :root:not([data-theme="light"]) .meeting-day {
        color: #63b3ed !important;
    }
}

/* 5. 사용자 봉사 일정 캘린더 모달 스타일 */
.user-calendar-modal {
    width: 92%;
    max-width: 460px;
    margin: auto;
    max-height: 88vh; /* 화면 높이에 최적화된 최대 높이 지정 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    border-radius: 20px !important; /* 모서리를 둥글고 세련되게 통일 */
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3) !important;
}

.user-calendar-body {
    padding: clamp(10px, 3vw, 15px);
    overflow: hidden; /* 바디 자체의 스크롤을 막아 달력이 고정되도록 함 */
    display: flex;
    flex-direction: column;
    gap: 8px; /* 모바일 세로 공간 효율을 위한 컴팩트한 간격 */
    flex: 1;
    box-sizing: border-box;
}

.user-calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    flex-shrink: 0; /* 크기 축소 차단 */
}

.user-calendar-nav .cal-btn {
    background: none;
    border: none;
    font-size: clamp(16px, 4.5vw, 20px);
    color: var(--text);
    cursor: pointer;
    padding: 2px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-calendar-nav .cal-btn:active {
    background: var(--bg-faint);
}

.user-calendar-nav span {
    font-weight: 700;
    font-size: clamp(13.5px, 3.8vw, 15.5px);
}

.user-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 700;
    font-size: clamp(10.5px, 3vw, 12px);
    margin-bottom: 2px;
    color: var(--text-muted);
    flex-shrink: 0; /* 크기 축소 차단 */
}

.user-calendar-days .sun {
    color: #ff6b6b;
}

.user-calendar-days .sat {
    color: #4dabf7;
}

.user-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: clamp(3px, 1vw, 5px);
    text-align: center;
    margin-bottom: 4px;
    flex-shrink: 0; /* 크기 축소 차단 */
}

.cal-day-cell {
    position: relative;
    padding: clamp(3px, 1vw, 6px) 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: clamp(11.5px, 3vw, 12.5px);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: clamp(30px, 8.5vw, 36px); /* 극소형 화면에서 찌그러짐을 완벽 방어하는 슬림 규격 */
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.cal-day-cell:active {
    transform: scale(0.92);
}

.cal-day-cell.empty {
    background: transparent;
    border: none;
    cursor: default;
    pointer-events: none;
}

.cal-day-cell.today {
    background: var(--accent-light, rgba(74, 144, 226, 0.1));
    border-color: var(--accent);
    color: var(--accent);
}

.cal-day-cell.selected {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
}

.cal-day-cell.sunday {
    color: #ff6b6b;
}

.cal-day-cell.saturday {
    color: #4dabf7;
}

.cal-day-cell.selected.sunday,
.cal-day-cell.selected.saturday {
    color: #fff !important;
}

.cal-day-cell.has-event {
    border-color: rgba(74, 144, 226, 0.4);
}

.cal-day-cell .event-dot {
    display: block;
    width: clamp(3px, 0.9vw, 4.5px);
    height: clamp(3px, 0.9vw, 4.5px);
    background: var(--accent);
    border-radius: 50%;
    margin-top: 1.5px;
}

.cal-day-cell.selected .event-dot {
    background: #fff;
}

.cal-day-cell.today .event-dot {
    background: var(--accent);
}

.user-calendar-detail {
    background: var(--bg-card, rgba(255, 255, 255, 0.05));
    border-radius: 12px;
    padding: clamp(10px, 3vw, 14px);
    font-size: clamp(12px, 3.2vw, 13.5px);
    border: 1px solid var(--border);
    transition: all 0.25s ease;
    flex: 1; /* 남은 여유 세로 공간을 꽉 채우도록 설정 */
    min-height: 120px; /* 상세 텍스트가 찌그러지지 않도록 탄탄한 안전 마진 확보 */
    max-height: 260px; /* 고해상도 화면에서 상세 카드가 비정상적으로 길어지는 것 제어 */
    overflow-y: auto; /* 오직 디테일 패널 내부에서만 부드럽게 세로 스크롤 활성화 */
    box-sizing: border-box;
}

.user-calendar-detail .detail-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 15px 0;
}

/* 화면 크기가 초소형(360px 이하)인 경우 미세 조정 */
@media (max-width: 360px) {
    .user-calendar-body {
        padding: 8px;
        gap: 6px;
    }
    
    .cal-day-cell {
        border-radius: 6px;
    }
    
    .user-calendar-detail {
        padding: 8px;
    }
}

/* 다크모드 대응 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .cal-day-cell {
        background: #252525;
        border-color: #333;
        color: #ddd;
    }
    
    :root:not([data-theme="light"]) .cal-day-cell.today {
        background: rgba(74, 144, 226, 0.2);
        border-color: var(--accent);
        color: #70b5ff;
    }
    
    :root:not([data-theme="light"]) .cal-day-cell.sunday {
        color: #ff8787;
    }
    
    :root:not([data-theme="light"]) .cal-day-cell.saturday {
        color: #74c0fc;
    }
    
    :root:not([data-theme="light"]) .cal-day-cell.selected {
        background: var(--accent) !important;
        border-color: var(--accent) !important;
        color: #fff !important;
    }
    
    :root:not([data-theme="light"]) .user-calendar-detail {
        background: rgba(0, 0, 0, 0.2) !important;
        border-color: #333 !important;
    }
}