html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
body, html { margin: 0; padding: 0; height: 100%; width: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f0f2f5; }
body.view-iframe { overflow: hidden; }
body.view-fallback { overflow: auto; }
.iframe-container { position: relative; width: 100%; height: 100%; }
.iframe-container iframe { width: 100%; height: 100%; border: none; }

/* THAY ĐỔI: Chuyển vị trí của toàn bộ khối điều khiển lên góc trên bên trái */
.iframe-controls {
    position: absolute;
    top: 50%;      
    right: 15px;     
    z-index: 9999;
}

.panha-logo-container { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.iframe-corner-logo { display: block; cursor: pointer; border-radius: 50%; box-shadow: 0 4px 8px rgba(0,0,0,0.2); opacity: 0.8; transition: opacity 0.2s ease, transform 0.2s ease-in-out; }
.iframe-corner-logo:hover { transform: scale(1.1); opacity: 1; }
.iframe-corner-logo img { width: 60px; height: auto; border-radius: 50%; display: block; }

.panha-menu {
    display: none;
    position: absolute;
    right: 100%;
    margin-right: 8px;
    
    /* MỚI: Di chuyển top menu đến 50% chiều cao của logo */
    top: 50%;
    /* MỚI: Dịch chuyển menu lên trên 50% chiều cao của chính nó để căn giữa tuyệt đối */
    transform: translateY(-50%);

    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    min-width: 150px;
    padding: 5px 0;
    z-index: 10000;
}

.panha-menu.show { display: block; }
.panha-menu a { display: block; padding: 10px 15px; color: #333; text-decoration: none; font-size: 14px; white-space: nowrap; cursor: pointer; }
.panha-menu a:hover { background-color: #f0f0f0; }

/* --- Các phần còn lại không thay đổi --- */
.fallback-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding: 20px; }
.fallback-card { background-color: #ffffff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.12); padding: 40px; width: 100%; max-width: 600px; text-align: center; }
.security-warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; border-radius: 8px; padding: 15px; margin-bottom: 20px; text-align: left; }
.fallback-logo { max-width: 120px; height: auto; margin-bottom: 25px; }
.fallback-card p { font-size: 16px; line-height: 1.6; color: #333; margin: 0 0 25px 0; word-break: break-word; }
.button-group { display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%; flex-wrap: wrap; }
.fallback-button { display: inline-block; padding: 14px 28px; background: linear-gradient(45deg, #007bff, #0056b3); color: white; text-decoration: none; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3); cursor: pointer; }
.fallback-button.disabled { background: #adb5bd; cursor: not-allowed; pointer-events: none; box-shadow: none; }
.fallback-button:not(.disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4); }
.copy-button { display: inline-flex; align-items: center; justify-content: center; padding: 14px; font-size: 18px; border-radius: 8px; border: 2px solid #6c757d; background-color: #fff; color: #6c757d; cursor: pointer; transition: background-color 0.2s, color 0.2s, border-color 0.2s; max-width: 100%; text-align: left; line-height: 1.4; }
.copy-button:hover { background-color: #6c757d; color: #fff; }
.subtext { font-size: 13px; color: #6c757d; margin-top: 20px; word-wrap: break-word; }
.subtext strong { color: #495057; }
.error-message-title { font-size: 24px; color: #dc3545; font-weight: bold; margin-bottom: 15px; }
.page-footer { margin-top: 30px; font-size: 12px; color: #888; text-align: center; }
.page-footer a { color: #555; text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }
.loading-spinner { border: 8px solid #f3f3f3; border-top: 8px solid #007bff; border-radius: 50%; width: 60px; height: 60px; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-text { font-size: 18px; color: #6c757d; }

@media (max-width: 640px) {
    .fallback-page { padding: 15px; }
    .fallback-card { padding: 25px 20px; }
    .fallback-logo { max-width: 100px; }
    .fallback-card p { font-size: 15px; }
    .error-message-title { font-size: 20px; }
    .fallback-button { padding: 12px 22px; font-size: 16px; }
    .copy-button { padding: 12px; font-size: 16px; }
    
    /* THAY ĐỔI: Cập nhật vị trí trên mobile */
    .iframe-controls {
        top: 50%;
        right: 10px;
    }

    .iframe-corner-logo img { width: 50px; }
    .panha-menu { min-width: 120px; }
    .panha-menu a { padding: 8px 10px; font-size: 12px; }
}