/* ══════════════════════════════════════════
   GONG GEN Z - PREMIUM FLIP PORTAL (2026)
   ══════════════════════════════════════════ */

:root {
    --nusantara-blue: #0857C3;
    --cakrawala-blue: #307FE2;
    --sky-blue: #71C5E8;
    
    /* ── Light Clean Theme ── */
    --bg-deep: #f0f4f9;                 /* Light grayish blue background */
    --glass-fill: rgba(255,255,255,0.95); /* Mostly solid white for cards */
    --glass-border: rgba(8,87,195,0.1);   /* Subtle blue border */
    --text-main: #1E3A8A;                /* Deep navy blue for texts instead of pure black */
    --text-dim: #475569;                 /* Steel blue for secondary text */
    --bento-shadow: 0 10px 30px rgba(8, 87, 195, 0.08); /* Soft blue outer shadow */
    --flip-digit-scale: 0.48;            /* multiplier for digit size relative to card height */
    /* Flip card colors */
    --flip-bg: #ffffff;
    --flip-bg-top: #f5f9ff;
    --flip-text: #1E3A8A;
}

body.dashboard-portal {
    background: var(--bg-deep);
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    overflow-x: hidden;
}

/* ── Fixed Executive Header ── */
.portal-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: rgba(255, 255, 255, 0.85); /* Light blur */
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
}

.portal-nav .logo img {
    height: 45px;
    filter: drop-shadow(0 0 10px rgba(113, 197, 232, 0.3));
}

/* Badges next to the portal title */
.portal-badges {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}
.portal-badge {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.9rem;
    border: 1px solid rgba(8,87,195,0.15);
    background: rgba(8,87,195,0.04);
    color: var(--text-main);
}
.portal-badge--accent {
    background: rgba(8,87,195,0.12);
    color: var(--nusantara-blue);
    border-color: var(--nusantara-blue);
}
.portal-badge--muted { background: rgba(8,87,195,0.05); }

/* ── Portal Menu ── */
.portal-menu {
    display: flex;
    align-items: center;
    gap: 40px;
}

.portal-menu .portal-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.portal-menu .portal-user .portal-user-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-dim);
}

.portal-menu a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 800;
    font-size: 0.95rem;
    transition: 0.3s;
}

.portal-menu a:hover {
    color: var(--nusantara-blue);
}

.portal-menu .dropdown {
    position: relative;
    display: inline-block;
}

/* Bridging the gap so hover doesn't drop */
.portal-menu .dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    height: 35px; /* Transparent touch zone */
    background: transparent;
    z-index: 999;
}

.portal-menu .dropbtn {
    display: flex;
    align-items: center;
}

.portal-menu .dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 25px); /* Position it nicely below */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--glass-fill);
    box-shadow: 0 10px 30px rgba(8, 87, 195, 0.1);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    padding: 10px 0;
    z-index: 1000;
}

.portal-menu .dropdown:hover .dropdown-content {
    display: block;
    animation: fadeInDrop 0.2s ease-out forwards;
}

@keyframes fadeInDrop {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.portal-menu .dropdown-content a {
    color: var(--text-dim);
    padding: 12px 20px;
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.portal-menu .dropdown-content a:hover {
    background-color: rgba(8, 87, 195, 0.05);
    color: var(--nusantara-blue);
}

.portal-nav .logout-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: 10px 24px;
    border-radius: 50px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.85rem;
    font-weight: 900;
    text-decoration: none;
    transition: 0.3s;
}

.portal-nav .logout-btn:hover {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

/* ── Portal Container ── */
.portal-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 120px 24px 80px;
    position: relative;
    z-index: 10;
}

/* ── Bento Grid ── */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

.bento-item {
    background-color: var(--glass-fill);
    /* Embedded SVG wave layered at the bottom for the exact theme style */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'%3E%3Cpath fill='rgba(8, 87, 195, 0.04)' d='M0,192L48,197.3C96,203,192,213,288,229.3C384,245,480,267,576,250.7C672,235,768,181,864,181.3C960,181,1056,235,1152,234.7C1248,235,1344,181,1392,154.7L1440,128L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z'%3E%3C/path%3E%3Cpath fill='rgba(113, 197, 232, 0.05)' d='M0,96L48,112C96,128,192,160,288,160C384,160,480,128,576,112C672,96,768,96,864,112C960,128,1056,160,1152,160C1248,160,1344,128,1392,112L1440,96L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: bottom;
    background-size: cover;
    backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    padding: 40px;
    position: relative;
    box-shadow: var(--bento-shadow); /* Soft shadow from new theme */
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.6s ease;
    will-change: transform;
    opacity: 0;
    transform: translateY(30px);
    /* NOTE: overflow:hidden is intentionally removed here.
     * It breaks CSS 3D perspective transforms (flip-card animation) in Chrome/Edge.
     * Rounded corners are preserved by border-radius on background; children are
     * not clipped, which is acceptable since content stays within bounds. */
}

/* allow children to shrink inside grid columns on small screens */
.bento-item { min-width: 0; }

.bento-item.visible { opacity: 1; transform: translateY(0); }

@media (min-width: 769px) and (max-width: 1200px) {
    /* Tablet landscape and small laptops: 2 columns */
    .bento-grid { grid-template-columns: repeat(2, 1fr); gap: 22px; }
    .bento-hero { grid-column: span 2; }

    /* Reduce the main title size on tablet so it doesn't overflow */
    .portal-title { font-size: clamp(2rem, 5.2vw, 3rem); }

    /* Slightly smaller badges and tighter spacing */
    .portal-badge { padding: 9px 16px; font-size: 0.85rem; }

    /* Slightly reduce internal padding for bento items on tablet */
    .bento-item { padding: 28px; border-radius: 28px; }
}

@media (max-width: 768px) {
    .bento-grid { grid-template-columns: 1fr; }
    .bento-hero, .bento-timer, .bento-action, .bento-resources, .bento-history { grid-column: span 1; }
}

/* Tighter mobile layout for bento grid */
@media (max-width: 768px) {
    .portal-container { padding: 90px 12px 40px; }
    .bento-grid { gap: 16px; }
    .bento-item {
        padding: 20px;
        border-radius: 18px;
        background-size: auto 60%;
    }
    .bento-item .portal-label { margin-bottom: 12px; }
    .portal-title { font-size: clamp(1.6rem, 6vw, 2.2rem); }

    /* Flip clock on mobile: override --flip-card-size only, rest auto-derives */
    .flip-clock { gap: 7px; margin-top: 18px; }
    .flip-card { --flip-card-size: 64px; }

    /* Ensure elements inside bento-items don't force wider min-content */
    .bento-item * { min-width: 0; }
}

/* Extra small screens */
@media (max-width: 420px) {
    .portal-container { padding: 80px 10px 30px; }
    .bento-item { padding: 16px; border-radius: 14px; }
    .flip-clock { gap: 5px; }
    .flip-card { --flip-card-size: 64px; }
}

/*
 * Tablet narrow (769–997px): 2-col grid, bento-timer is half-width.
 * At 769px content area ≈ 285px — 4×90px cards (408px) overflow → Secs drops.
 * 4×64px + 3×8px = 280px ≤ 285px ✓
 */
@media (min-width: 769px) and (max-width: 997px) {
    .flip-clock { gap: 8px; }
    .flip-card { --flip-card-size: 64px; }
}

/*
 * Tablet wide (998–1200px): content area ≈ 360–460px.
 * 4×80px + 3×10px = 350px ≤ 360px ✓
 */
@media (min-width: 998px) and (max-width: 1200px) {
    .flip-clock { gap: 10px; }
    .flip-card { --flip-card-size: 80px; }
}

/* Larger screens (≥1201px): bigger flip cards */
@media (min-width: 1201px) {
    .flip-clock { gap: 14px; }
    .flip-card { --flip-card-size: 100px; }
}

/* Mobile adjustments for portal-nav and mobile menu */
@media (max-width: 768px) {
    .portal-menu { display: none; }
    .portal-nav { padding: 0 18px; height: 64px; }
    .portal-nav .hamburger { display: flex; margin-left: 12px; }
    .portal-nav .mobile-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; z-index: 1100; background: var(--glass-fill); padding: 12px 18px; border-bottom: 1px solid var(--glass-border); box-shadow: 0 10px 30px rgba(8,87,195,0.07); }
    .portal-nav .mobile-nav.open { display: flex; flex-direction: column; gap: 8px; }
    .portal-nav .mobile-nav .mobile-nav-link { padding: 10px 8px; font-weight: 800; color: var(--text-main); text-decoration: none; }
    .portal-nav .mobile-actions { margin-top: 8px; display:flex; gap: 8px; align-items:center; justify-content:space-between; }
}

/* ══════════════════════════════════════════
   4-LAYER MECHANICAL FLIP CLOCK
   ══════════════════════════════════════════ */

.flip-clock {
    display: flex;
    flex-wrap: nowrap;      /* cards NEVER wrap — size controlled per breakpoint */
    justify-content: center;
    align-items: flex-start;
    gap: 14px;
    margin-top: 24px;
    width: 100%;
}

.flip-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/*
 * --flip-card-size: override this ONE variable in media queries.
 * --flip-card-height, --flip-half, --flip-font all derive from it automatically.
 * NO overflow:hidden — perspective + overflow:hidden hides 3D layers in Chrome/Edge.
 */
.flip-card {
    position: relative;
    --flip-card-size:   80px;
    --flip-card-height: calc(var(--flip-card-size) * 1.22);
    --flip-half:        calc(var(--flip-card-height) / 2);
    --flip-font:        calc(var(--flip-card-size) * 0.56);
    width:  var(--flip-card-size);
    height: var(--flip-card-height);
    border-radius: 10px;
    perspective: 800px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(8, 87, 195, 0.13);
    border: 1px solid rgba(8, 87, 195, 0.08);
}

.card-layer {
    position: absolute;
    left: 0;
    width: 100%;
    overflow: hidden;
    background: #ffffff;
    /*
     * NO backface-visibility here: it creates a stacking context where
     * ::after (z-index 1) renders above the digit span (z-index auto = 0).
     * Applied only to the flipping layers (.top-flip, .bottom-flip) below.
     */
}

/* Digit: height = full card so each half-layer clips it correctly at the fold */
.card-layer span {
    display: block;
    position: absolute;
    left: 0;
    width: 100%;
    height:      var(--flip-card-height);
    line-height: var(--flip-card-height);
    font-size:   var(--flip-font);
    font-weight: 900;
    text-align:  center;
    color: #1E3A8A;
    z-index: 2;   /* above ::after overlay (z-index 1) */
}

/* top half */
.top-side {
    top: 0;
    height: var(--flip-half);
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid rgba(8, 87, 195, 0.12);
}
.top-side span { top: 0; }
.top-side::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
    pointer-events: none;
    z-index: 1;
}

/* bottom half */
.bottom-side {
    bottom: 0;
    height: var(--flip-half);
    border-radius: 0 0 10px 10px;
}
.bottom-side span { bottom: 0; }
.bottom-side::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(8, 87, 195, 0.04), transparent);
    pointer-events: none;
    z-index: 1;
}

/* z-index hierarchy */
.top-static    { z-index: 2; }
.bottom-static { z-index: 2; }
.top-flip {
    z-index: 4;
    transform-origin: bottom center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.bottom-flip {
    z-index: 3;
    transform-origin: top center;
    transform: rotateX(90deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* animations */
@keyframes flipDown {
    0%   { transform: rotateX(0deg); }
    100% { transform: rotateX(-90deg); }
}
@keyframes flipUp {
    0%   { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}
.flip-animate .top-flip {
    animation: flipDown 0.3s ease-in forwards;
    z-index: 10;
}
.flip-animate .bottom-flip {
    animation: flipUp 0.3s ease-out 0.3s forwards;
    z-index: 9;
}
.flip-animate .top-flip::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 60%, rgba(8, 87, 195, 0.10));
    pointer-events: none;
}

/* Explicit override placed after defaults: ensure mobile & tablet-portrait use 64px */
@media (max-width: 768px), (min-width: 769px) and (max-width: 997px) {
    .flip-card { --flip-card-size: 64px; }
}

.flip-label {
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--text-dim, #475569);
    letter-spacing: 0.14em;
}

/* Compact flip used inside deadline pills */
.pill-flip { vertical-align: middle; }
.pill-flip .flip-card { --flip-card-size: 40px; }
.pill-flip .flip-label { font-size: 0.6rem; font-weight:800; text-transform:none; letter-spacing:0.06em; color:var(--text-dim); }

/* ── Component Styles ── */
.portal-label {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--nusantara-blue); /* Deeper blue for labels */
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-bottom: 25px;
}

.portal-title {
    font-size: clamp(2.4rem, 5.2vw, 4rem);
    font-weight: 950;
    line-height: 0.9;
    letter-spacing: -0.05em;
}

.btn-gong {
    background: linear-gradient(180deg, #5CA0F2 0%, #0857C3 100%);
    color: #ffffff;
    border: 1px solid rgba(8, 87, 195, 0.8);
    box-shadow: 0 10px 25px rgba(8, 87, 195, 0.35), inset 0 2px 2px rgba(255, 255, 255, 0.35); /* Glossy bevel & drop shadow */
    border-radius: 60px;
    padding: 22px 50px;
    font-weight: 950;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-gong:hover {
    transform: scale(1.05) rotate(-1.5deg);
    box-shadow: 0 15px 35px rgba(8, 87, 195, 0.45), inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

.btn-static {
    background: linear-gradient(180deg, #5CA0F2 0%, #0857C3 100%);
    color: #ffffff;
    border: 1px solid rgba(8, 87, 195, 0.8);
    box-shadow: 0 8px 20px rgba(8, 87, 195, 0.25), inset 0 2px 2px rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 16px 35px;
}

/* Small inline View button used next to filenames */
.btn-view {
    display: inline-block;
    background: #ffffff;
    color: var(--nusantara-blue);
    border: 1px solid rgba(8,87,195,0.12);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.9rem;
    text-decoration: none;
    box-shadow: 0 6px 14px rgba(8,87,195,0.06);
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn-view:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(8,87,195,0.12);
    background: linear-gradient(180deg, rgba(8,87,195,0.03), #ffffff);
}
.btn-view:focus {
    outline: 3px solid rgba(8,87,195,0.12);
    outline-offset: 2px;
}

/* ==========================
   File input / upload styles
   ========================== */
.file-input,
input[type="file"] {
    width: 100%;
    flex: 1 1 auto;
    font-weight: 700;
    color: var(--text-main);
    background: #ffffff;
    border: 1px solid rgba(8,87,195,0.08);
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(8,87,195,0.06);
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .08s;
    outline: none;
}

.file-input:focus {
    border-color: var(--nusantara-blue);
    box-shadow: 0 10px 30px rgba(8,87,195,0.08);
}

/* Modern browsers: style the file selector button */
.file-input::file-selector-button {
    background: linear-gradient(180deg, #5CA0F2 0%, #0857C3 100%);
    color: #ffffff;
    border: none;
    padding: 8px 12px;
    margin-right: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

/* WebKit fallback */
.file-input::-webkit-file-upload-button {
    background: linear-gradient(180deg, #5CA0F2 0%, #0857C3 100%);
    color: #ffffff;
    border: none;
    padding: 8px 12px;
    margin-right: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

/* IE / Edge legacy */
.file-input::-ms-browse {
    background: linear-gradient(180deg, #5CA0F2 0%, #0857C3 100%);
    color: #ffffff;
    border: none;
    padding: 8px 12px;
    margin-right: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

/* Ensure bento-timer block is always visible (not blocked by data-animate fade-in) */
.bento-item.bento-timer {
    opacity: 1 !important;
    transform: none !important;
}