/*
 * Papan jadwal ruang meeting — client/data_booking_ruang_meeting.php
 * Tampilan disamakan dengan papan kendaraan (assets/css/data-booking-mobil.css). Struktur kartu dari
 * server tidak diubah; tampilan memakai kelas yang ada dan atribut dari JS (data-status, data-when,
 * data-when-label, is-new / is-changed). CSP: style-src 'self', img-src 'self' data: — ikon ruang
 * memakai data URI di CSS, tanpa atribut style.
 */

/* ── Token ─────────────────────────────────────────────────────────────── */
:root {
    color-scheme: light;

    --bg: #f3f6fb;
    --glow-1: rgba(59, 130, 246, .12);
    --glow-2: rgba(99, 102, 241, .10);
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --surface-3: #edf1f7;

    --text: #0f172a;
    --text-2: #475569;
    --muted: #64748b;
    --line: #e3e8f0;
    --line-strong: #cfd7e3;

    --primary: #2563eb;
    --primary-2: #4f46e5;
    --primary-text: #1d4ed8;
    --primary-soft: #eef3ff;
    --primary-line: #bfd0fb;
    --primary-ring: rgba(37, 99, 235, .22);

    --success: #059669;
    --success-text: #047857;
    --success-soft: #e7f7ee;
    --success-line: #a7e3c4;
    --warning: #d97706;
    --warning-text: #92400e;
    --warning-soft: #fff7e6;
    --warning-line: #fcd38a;
    --danger: #dc2626;
    --danger-text: #b42318;
    --danger-soft: #fef3f2;
    --danger-line: #f8c4c4;

    --accent: var(--primary);
    --accent-2: var(--primary-2);

    /* ikon ruang meeting (papan presentasi), warna = --primary-text */
    --room-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d4ed8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h20'/%3E%3Cpath d='M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3'/%3E%3Cpath d='m7 21 5-5 5 5'/%3E%3C/svg%3E");

    --radius: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 6px -2px rgba(15, 23, 42, .06);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px -12px rgba(15, 23, 42, .16);
    --shadow-lg: 0 2px 4px rgba(15, 23, 42, .04), 0 24px 48px -16px rgba(15, 23, 42, .26);

    --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #0a0f1c;
        --glow-1: rgba(59, 130, 246, .16);
        --glow-2: rgba(99, 102, 241, .12);
        --surface: #111a2b;
        --surface-2: #162036;
        --surface-3: #1d2941;

        --text: #e6ebf4;
        --text-2: #b6c2d6;
        --muted: #8b99b2;
        --line: #233049;
        --line-strong: #33445f;

        --primary: #3b6cf0;
        --primary-2: #6366f1;
        --primary-text: #8db1ff;
        --primary-soft: rgba(96, 140, 255, .14);
        --primary-line: rgba(96, 140, 255, .42);
        --primary-ring: rgba(96, 140, 255, .34);

        --success: #34d399;
        --success-text: #6ee7b7;
        --success-soft: rgba(52, 211, 153, .12);
        --success-line: rgba(52, 211, 153, .34);
        --warning: #fbbf24;
        --warning-text: #fcd34d;
        --warning-soft: rgba(251, 191, 36, .10);
        --warning-line: rgba(251, 191, 36, .34);
        --danger: #f87171;
        --danger-text: #fca5a5;
        --danger-soft: rgba(248, 113, 113, .10);
        --danger-line: rgba(248, 113, 113, .36);

        --room-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238db1ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h20'/%3E%3Cpath d='M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3'/%3E%3Cpath d='m7 21 5-5 5 5'/%3E%3C/svg%3E");

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 30px -12px rgba(0, 0, 0, .6);
        --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 26px 50px -16px rgba(0, 0, 0, .75);
    }
}

/* ── Dasar ─────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

body {
    min-height: 100vh;
    padding: 2.25rem 1.5rem 3rem;
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 480px at 10% -10%, var(--glow-1), transparent 70%),
        radial-gradient(800px 420px at 95% 0%, var(--glow-2), transparent 70%);
    background-repeat: no-repeat;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
    color: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.container {
    position: relative;
    max-width: 1240px;
    margin: 0 auto;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    text-align: center;
    animation: fadeDown .6s ease-out;
}

.header h1 {
    margin-bottom: .6rem;
    background: linear-gradient(120deg, #0f172a 10%, #1d4ed8 55%, #4f46e5 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    font-size: clamp(1.85rem, 1.25rem + 2.4vw, 2.9rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -.03em;
}

@media (prefers-color-scheme: dark) {
    .header h1 {
        background-image: linear-gradient(120deg, #f8fafc 10%, #a9c3ff 60%, #c4b5fd 95%);
    }
}

.header p {
    max-width: 560px;
    color: var(--text-2);
    font-size: clamp(.95rem, .9rem + .3vw, 1.08rem);
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .75rem 1rem;
    margin-top: 1.1rem;
}

/* ── Status pembaruan otomatis ─────────────────────────────────────────── */
.live-status {
    --live-color: var(--success);
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    min-height: 40px;
    padding: .25rem .25rem .25rem .9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    box-shadow: var(--shadow-sm);
    color: var(--text-2);
    font-size: .8rem;
    font-weight: 500;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transition: border-color .2s ease;
}

.live-status[data-state="retrying"] {
    --live-color: var(--warning);
    border-color: var(--warning-line);
}

.live-status[data-state="offline"] {
    --live-color: var(--danger);
    border-color: var(--danger-line);
}

.live-dot {
    position: relative;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--live-color);
}

.live-dot::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--live-color);
    opacity: 0;
}

.live-status[data-state="live"] .live-dot::after {
    animation: ping 2s ease-out infinite;
}

.live-text {
    color: var(--text);
    font-weight: 600;
}

.live-status[data-state="retrying"] .live-text { color: var(--warning-text); }
.live-status[data-state="offline"] .live-text { color: var(--danger-text); }

.live-time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.refresh-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-btn:hover {
    background: var(--primary-soft);
    color: var(--primary-text);
}

.refresh-btn:disabled {
    cursor: default;
}

.refresh-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.live-status.is-syncing .refresh-btn svg {
    animation: spin .9s linear infinite;
}

.noscript-note {
    margin-bottom: 1.25rem;
    padding: .85rem 1rem;
    border: 1px solid var(--warning-line);
    border-radius: 14px;
    background: var(--warning-soft);
    color: var(--warning-text);
    font-weight: 500;
    text-align: center;
}

/* ── Grid ──────────────────────────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 1.5rem;
}

/* ── Kartu ─────────────────────────────────────────────────────────────── */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 1.45rem 1.5rem 1.1rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform .3s cubic-bezier(.2, .7, .2, 1), box-shadow .3s ease, border-color .3s ease;
}

/* aksen atas & cahaya sudut mengikuti status */
.card[data-status="booked"] { --accent: #10b981; --accent-2: #0d9488; }
.card[data-status="pending"] { --accent: #f59e0b; --accent-2: #f97316; }

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.card::after {
    content: "";
    position: absolute;
    top: -90px;
    right: -90px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 14%, transparent), transparent);
    opacity: .7;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lg);
}

.card:hover::after {
    opacity: 1;
    transform: scale(1.15);
}

.card > * {
    position: relative;
    z-index: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1.1rem;
}

.room-name {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
}

/* ikon ruang dalam ubin, sama seperti ikon kendaraan */
.room-name::before {
    content: "";
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-soft) var(--room-icon) center / 22px no-repeat;
    transition: transform .3s cubic-bezier(.2, .7, .2, 1);
}

.card:hover .room-name::before {
    transform: rotate(-6deg) scale(1.06);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
    margin-top: .45rem;
    padding: .32rem .75rem;
    border: 1px solid;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.status-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-booked {
    border-color: var(--success-line);
    background: var(--success-soft);
    color: var(--success-text);
}

.status-booked::before {
    animation: badgePulse 2.4s ease-out infinite;
}

.status-pending {
    border-color: var(--warning-line);
    background: var(--warning-soft);
    color: var(--warning-text);
}

.status-pending::before {
    animation: blink 1.6s ease-in-out infinite;
}

.card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: .35rem;
}

.info-row {
    display: flex;
    align-items: flex-start;
    gap: .8rem;
    padding: .55rem .6rem;
    border: 1px solid transparent;
    border-radius: 14px;
    transition: background-color .2s ease, border-color .2s ease;
}

.info-row:hover {
    background: var(--surface-2);
}

/* baris "Waktu Pelaksanaan" ditonjolkan */
.info-row:first-child {
    margin-bottom: .25rem;
    padding: .75rem .8rem;
    border-color: var(--line);
    background: var(--surface-2);
}

.info-icon {
    flex: none;
    width: 34px;
    height: 34px;
    padding: 7px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.info-row:first-child .info-icon {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.info-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-top: 1px;
}

.info-label {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.info-value {
    display: block;
    color: var(--text);
    font-size: .95rem;
    font-weight: 500;
    line-height: 1.4;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.info-value strong {
    font-weight: 700;
}

/* label waktu relatif dari JS: "Hari ini · dalam 2 jam", "Besok", "Dalam 3 hari" */
.info-value[data-when-label]::after {
    content: attr(data-when-label);
    display: table; /* selalu baris sendiri, lebar mengikuti teks */
    margin: .35rem 0 0;
    padding: .1rem .55rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-text);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .01em;
    white-space: nowrap;
}

.card[data-when="today"] .info-value[data-when-label]::after {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
}

.card[data-when="today"] {
    border-color: var(--primary-line);
    box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-sm);
}

.card[data-when="today"] .info-row:first-child {
    border-color: var(--primary-line);
    background: var(--primary-soft);
}

.agenda-text {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-2);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px dashed var(--line-strong);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 500;
}

.card-footer > span:first-child {
    padding: .1rem .5rem;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text-2);
    font-family: var(--mono);
    font-weight: 600;
}

.card-footer > span:last-child {
    font-variant-numeric: tabular-nums;
}

/* ── Animasi masuk & sorotan pembaruan ─────────────────────────────────── */
/*
 * Animasi masuk hanya saat halaman pertama dibuka. Saat pembaruan AJAX, JS melepas .is-initial
 * supaya kartu yang dipindah tidak beranimasi ulang; hanya kartu baru / berubah yang disorot.
 */
.grid.is-initial .card {
    animation: cardIn .55s cubic-bezier(.2, .7, .2, 1) backwards;
}

.grid.is-initial .card:nth-child(2) { animation-delay: .04s; }
.grid.is-initial .card:nth-child(3) { animation-delay: .08s; }
.grid.is-initial .card:nth-child(4) { animation-delay: .12s; }
.grid.is-initial .card:nth-child(5) { animation-delay: .16s; }
.grid.is-initial .card:nth-child(6) { animation-delay: .2s; }
.grid.is-initial .card:nth-child(7) { animation-delay: .24s; }
.grid.is-initial .card:nth-child(8) { animation-delay: .28s; }
.grid.is-initial .card:nth-child(n+9) { animation-delay: .32s; }

.card.is-new {
    animation: cardIn .55s cubic-bezier(.2, .7, .2, 1) backwards, highlight 3s ease-out;
}

.card.is-changed {
    animation: highlight 3s ease-out;
}

.card.is-new::before,
.card.is-changed::before {
    height: 5px;
}

/* ── Keadaan kosong / error ────────────────────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 4rem 2rem;
    border: 1.5px dashed var(--line-strong);
    border-radius: 24px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: .75rem;
    padding: 16px;
    border-radius: 20px;
    background: var(--surface-3);
    color: var(--muted);
}

.empty-state h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.empty-state p {
    max-width: 460px;
    color: var(--text-2);
}

.empty-state.is-error {
    border-color: var(--danger-line);
    background: var(--danger-soft);
}

.empty-state.is-error h2 {
    color: var(--danger-text);
}

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: none; }
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(18px) scale(.98); }
    to { opacity: 1; transform: none; }
}

@keyframes highlight {
    0%, 35% { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring), var(--shadow-lg); }
    100% { box-shadow: var(--shadow-sm); }
}

@keyframes badgePulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
    70%, 100% { box-shadow: 0 0 0 6px transparent; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

@keyframes ping {
    0% { transform: scale(.6); opacity: .45; }
    100% { transform: scale(1.9); opacity: 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Responsif ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    body {
        padding: 1.5rem 1rem 2.5rem;
        font-size: 14px;
    }

    .header {
        margin-bottom: 1.5rem;
    }

    .header-actions,
    .live-status {
        width: 100%;
    }

    .live-text {
        flex: 1;
        min-width: 0;
        text-align: left;
    }

    .grid {
        gap: 1rem;
    }

    .card {
        padding: 1.25rem 1.15rem 1rem;
        border-radius: 18px;
    }

    .room-name {
        font-size: 1.18rem;
    }

    .card-footer {
        flex-wrap: wrap;
    }

    .empty-state {
        padding: 3rem 1.5rem;
    }
}

@media (hover: none) {
    .card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
