<?php
$timezone = 'Asia/Kuala_Lumpur';
date_default_timezone_set($timezone);
?>
<style>
.clock-3d {
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    width: 100%;
}
.clock-face {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 40px 50px;
    border-radius: 20px;
    width: 100%;
    transform: rotateX(3deg);
    box-shadow:
        0 25px 50px -12px rgba(0,0,0,0.15),
        0 0 0 1px rgba(0,0,0,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8),
        inset 0 -1px 0 rgba(0,0,0,0.06),
        0 8px 0 #cbd5e1;
    border: 1px solid rgba(0,0,0,0.04);
    position: relative;
    transition: transform 0.3s ease;
    box-sizing: border-box;
}
.clock-face:hover {
    transform: rotateX(1deg) translateY(-2px);
    box-shadow:
        0 30px 60px -12px rgba(0,0,0,0.2),
        0 0 0 1px rgba(0,0,0,0.05),
        inset 0 1px 0 rgba(255,255,255,0.8),
        inset 0 -1px 0 rgba(0,0,0,0.06),
        0 6px 0 #cbd5e1;
}
.clock-face::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255,255,255,0.6) 0%, transparent 40%, rgba(0,0,0,0.03) 100%);
    pointer-events: none;
}
.clock-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    position: relative;
    z-index: 1;
}
.clock-brand {
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 600;
}
.clock-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    font-size: 11px;
    font-family: system-ui, -apple-system, sans-serif;
}
.clock-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.4);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.clock-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}
.clock-digit-group {
    display: flex;
    gap: 6px;
}
.clock-digit {
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    color: #1e293b;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 64px;
    font-weight: 300;
    padding: 12px 16px;
    border-radius: 10px;
    min-width: 56px;
    text-align: center;
    box-shadow:
        inset 0 2px 6px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8),
        0 2px 0 #cbd5e1,
        0 4px 12px rgba(0,0,0,0.06);
    line-height: 1;
    letter-spacing: 1px;
}
.clock-separator {
    color: #94a3b8;
    font-size: 52px;
    font-weight: 300;
    line-height: 1;
    padding-bottom: 6px;
    animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
.clock-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 24px;
    position: relative;
    z-index: 1;
}
.clock-date {
    color: #64748b;
    font-size: 13px;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 400;
    letter-spacing: 0.3px;
}
.clock-timezone {
    color: #94a3b8;
    font-size: 11px;
    font-family: system-ui, -apple-system, sans-serif;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.clock-accent {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.06), transparent);
    border-radius: 1px;
    pointer-events: none;
}
@media (max-width: 1024px) {
    .clock-digit { font-size: 48px; padding: 10px 12px; min-width: 42px; }
    .clock-separator { font-size: 40px; }
    .clock-face { padding: 30px 36px; }
}
@media (max-width: 640px) {
    .clock-face {
        padding: 20px 16px;
        border-radius: 16px;
        transform: rotateX(1deg);
        box-shadow:
            0 20px 40px -12px rgba(0,0,0,0.12),
            0 0 0 1px rgba(0,0,0,0.04),
            inset 0 1px 0 rgba(255,255,255,0.8),
            inset 0 -1px 0 rgba(0,0,0,0.06),
            0 4px 0 #cbd5e1;
    }
    .clock-display { gap: 6px; }
    .clock-digit-group { gap: 4px; }
    .clock-digit {
        font-size: 28px;
        padding: 6px 8px;
        min-width: 24px;
        border-radius: 8px;
    }
    .clock-separator { font-size: 24px; padding-bottom: 2px; }
    .clock-top-bar { margin-bottom: 16px; }
    .clock-bottom {
        flex-direction: column;
        align-items: center;
        gap: 4px;
        margin-top: 14px;
    }
    .clock-brand { font-size: 9px; letter-spacing: 2px; }
    .clock-status { font-size: 9px; }
    .clock-date { font-size: 11px; }
    .clock-timezone { font-size: 9px; }
}
@media (max-width: 380px) {
    .clock-digit { font-size: 22px; padding: 4px 6px; min-width: 20px; }
    .clock-separator { font-size: 18px; }
    .clock-face { padding: 14px 10px; }
}
</style>
<div class="clock-3d">
    <div class="clock-face">
        <div class="clock-top-bar">
            <span class="clock-brand">System Clock</span>
            <span class="clock-status">
                <span class="clock-status-dot"></span>
                Live
            </span>
        </div>
        <div class="clock-display">
            <div class="clock-digit-group">
                <div class="clock-digit" id="clock-h1">0</div>
                <div class="clock-digit" id="clock-h2">0</div>
            </div>
            <div class="clock-separator">:</div>
            <div class="clock-digit-group">
                <div class="clock-digit" id="clock-m1">0</div>
                <div class="clock-digit" id="clock-m2">0</div>
            </div>
            <div class="clock-separator">:</div>
            <div class="clock-digit-group">
                <div class="clock-digit" id="clock-s1">0</div>
                <div class="clock-digit" id="clock-s2">0</div>
            </div>
        </div>
        <div class="clock-bottom">
            <span class="clock-date" id="clock-date"></span>
            <span class="clock-timezone"><?= $timezone ?></span>
        </div>
        <div class="clock-accent"></div>
    </div>
</div>
<script>
(function() {
    function pad(n) { return n.toString().padStart(2, '0'); }
    var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
    var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
    function update() {
        var d = new Date();
        var h = pad(d.getHours());
        var m = pad(d.getMinutes());
        var s = pad(d.getSeconds());
        var el = function(id) { return document.getElementById(id); };
        el('clock-h1').textContent = h[0];
        el('clock-h2').textContent = h[1];
        el('clock-m1').textContent = m[0];
        el('clock-m2').textContent = m[1];
        el('clock-s1').textContent = s[0];
        el('clock-s2').textContent = s[1];
        var de = el('clock-date');
        if (de && !de.dataset.set) {
            de.textContent = days[d.getDay()] + ', ' + d.getDate() + ' ' + months[d.getMonth()] + ' ' + d.getFullYear();
            de.dataset.set = '1';
        }
    }
    update();
    setInterval(update, 1000);
})();
</script>