/* =======================================================
   KC Presence – KC-Bar Widget
   Dark theme, matches original Kiwanis Club prototype
   ======================================================= */

.kc-presence {
    --kc-bg-deep:      #0a0a0f;
    --kc-bg-card:      #15151c;
    --kc-bg-hover:     #1e1e27;
    --kc-border:       #252530;
    --kc-text-primary: #f0f0f5;
    --kc-text-secondary: #9a9aaa;
    --kc-text-muted:   #6a6a78;
    --kc-accent:       #2dd4bf;
    --kc-accent-dim:   #0d9488;
    --kc-danger:       #ef4444;
    --kc-gold:         #FFD700;

    max-width: 480px;
    margin: 2rem auto;
    padding: 0;
    background: var(--kc-bg-deep);
    color: var(--kc-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
    position: relative;
    -webkit-font-smoothing: antialiased;
}

.kc-presence *, .kc-presence *::before, .kc-presence *::after { box-sizing: border-box; }

/* === Header === */
.kc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px 18px;
    background: linear-gradient(180deg, rgba(255,215,0,0.06) 0%, transparent 100%);
    border-bottom: 1px solid var(--kc-border);
}
.kc-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.kc-header-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255,215,0,0.1);
    border-radius: 12px;
    border: 1px solid rgba(255,215,0,0.2);
}
.kc-header-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.kc-header-sub {
    font-size: 12px;
    color: var(--kc-text-secondary);
    margin-top: 2px;
}
.kc-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.kc-fs-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--kc-text-muted);
    background: transparent;
    border: 1px solid var(--kc-border);
    border-radius: 8px;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.kc-fs-link:hover {
    color: var(--kc-text-primary);
    border-color: var(--kc-text-muted);
    background: var(--kc-bg-card);
}
/* Hide fullscreen link inside the fullscreen page itself (belt-and-braces; PHP also guards) */
.kc-fullscreen .kc-fs-link { display: none; }

.kc-badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    background: rgba(45,212,191,0.12);
    color: var(--kc-accent);
    border: 1px solid rgba(45,212,191,0.3);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}
.kc-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--kc-accent);
    box-shadow: 0 0 0 0 rgba(45,212,191,0.5);
    animation: kc-pulse 2s infinite;
}
@keyframes kc-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(45,212,191,0.6); }
    70%  { box-shadow: 0 0 0 7px rgba(45,212,191,0); }
    100% { box-shadow: 0 0 0 0 rgba(45,212,191,0); }
}
.kc-count-label { margin-left: 2px; }

/* === Content area === */
.kc-content {
    padding: 20px 18px 24px;
}

/* === Login gate === */
.kc-login-gate {
    text-align: center;
    padding: 36px 20px;
}
.kc-login-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.7;
}
.kc-login-text {
    color: var(--kc-text-secondary);
    margin-bottom: 18px;
    font-size: 15px;
}
.kc-btn-login {
    display: inline-block;
    padding: 12px 28px;
    background: var(--kc-gold);
    color: #1a1a1a;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s;
}
.kc-btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255,215,0,0.25);
}

/* === Check-in button === */
.kc-btn-checkin {
    width: 100%;
    padding: 18px 20px;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    font-family: inherit;
    color: #0a0a0f;
    letter-spacing: -0.01em;
}
.kc-btn-checkin:disabled {
    opacity: 0.6;
    cursor: wait;
}
.kc-btn-checkin:not(:disabled):hover { transform: translateY(-2px); }
.kc-btn-checkin:not(:disabled):active { transform: translateY(0); }

.kc-btn-checkin.kc-state-out {
    background: linear-gradient(135deg, #ffd700, #f5c116);
    box-shadow: 0 8px 24px rgba(255,215,0,0.25);
}
.kc-btn-checkin.kc-state-out:not(:disabled):hover {
    box-shadow: 0 12px 32px rgba(255,215,0,0.35);
}
.kc-btn-checkin.kc-state-in {
    background: linear-gradient(135deg, #2dd4bf, #0d9488);
    color: white;
    box-shadow: 0 8px 24px rgba(45,212,191,0.25);
}
.kc-btn-checkin.kc-state-in:not(:disabled):hover {
    box-shadow: 0 12px 32px rgba(45,212,191,0.35);
}
.kc-btn-icon { font-size: 20px; line-height: 1; }

/* === Auto-checkout hint === */
.kc-auto-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--kc-text-muted);
    animation: kc-fade-up 0.3s ease-out;
}
@keyframes kc-fade-up {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === Tabs === */
.kc-tabs {
    display: flex;
    gap: 4px;
    margin: 22px 0 14px;
    padding: 4px;
    background: var(--kc-bg-card);
    border-radius: 12px;
    border: 1px solid var(--kc-border);
}
.kc-tab {
    flex: 1;
    padding: 9px;
    background: transparent;
    color: var(--kc-text-secondary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.kc-tab:hover { color: var(--kc-text-primary); }
.kc-tab.kc-tab-active {
    background: var(--kc-bg-hover);
    color: var(--kc-text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* === Section visibility === */
.kc-section { display: none; }
.kc-section.kc-section-active { display: block; }

/* === Lists === */
.kc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kc-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--kc-text-muted);
    font-size: 14px;
}

/* === Member row === */
.kc-member, .kc-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    background: var(--kc-bg-card);
    border: 1px solid var(--kc-border);
    border-radius: 12px;
    opacity: 0;
    transform: translateY(8px);
    animation: kc-slide-in 0.35s ease-out forwards;
}
@keyframes kc-slide-in {
    to { opacity: 1; transform: translateY(0); }
}
.kc-member.kc-is-self, .kc-history-item.kc-is-self {
    border-color: rgba(45,212,191,0.3);
    background: rgba(45,212,191,0.05);
}

/* === Avatar === */
.kc-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kc-bg-hover);
    color: white;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
}
.kc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.kc-avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Member info === */
.kc-member-info {
    flex: 1;
    min-width: 0;
}
.kc-member-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--kc-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.kc-tag-self {
    display: inline-block;
    padding: 1px 7px;
    background: rgba(45,212,191,0.15);
    color: var(--kc-accent);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.kc-member-time, .kc-history-times {
    font-size: 12px;
    color: var(--kc-text-secondary);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
}
.kc-arrow {
    color: var(--kc-text-muted);
    margin: 0 4px;
}
.kc-auto-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: var(--kc-bg-hover);
    color: var(--kc-text-muted);
    border-radius: 4px;
    font-size: 10px;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.kc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--kc-accent);
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(45,212,191,0.5);
}

/* === History groups === */
.kc-day-group { margin-bottom: 16px; }
.kc-day-group:last-child { margin-bottom: 0; }
.kc-day-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--kc-text-muted);
    padding: 4px 2px 8px;
    border-bottom: 1px solid var(--kc-border);
    margin-bottom: 8px;
}

/* === Responsive === */
@media (max-width: 520px) {
    .kc-presence {
        margin: 1rem auto;
        border-radius: 16px;
    }
    .kc-header { padding: 16px 18px 14px; }
    .kc-header-title { font-size: 16px; }
    .kc-content { padding: 16px 14px 20px; }
    .kc-btn-checkin { font-size: 16px; padding: 16px 18px; }
}

/* === Fullscreen page overrides === */
.kc-fullscreen .kc-presence {
    max-width: 520px;
}
@media (min-width: 768px) {
    .kc-fullscreen .kc-presence {
        max-width: 560px;
    }
    .kc-fullscreen .kc-header { padding: 24px 26px 20px; }
    .kc-fullscreen .kc-header-title { font-size: 20px; }
    .kc-fullscreen .kc-content { padding: 24px 22px 28px; }
    .kc-fullscreen .kc-btn-checkin {
        padding: 22px 24px;
        font-size: 19px;
        border-radius: 16px;
    }
    .kc-fullscreen .kc-btn-icon { font-size: 24px; }
}

/* === Respect prefers-reduced-motion === */
@media (prefers-reduced-motion: reduce) {
    .kc-member, .kc-history-item, .kc-badge-dot, .kc-auto-hint {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .kc-btn-checkin { transition: none !important; }
}
