/* ==========================================================================
   PICOQUANT PRO - GLOBAL APP SHELL (MAIN.CSS)
   ========================================================================== */

/* --- 1. SYSTEM VARIABLES --- */
:root {
    --bg-main: #05070a;
    --bg-panel: rgba(13, 17, 23, 0.7);
    --bg-deep: #05070a;              /* Đen sâu thẳm */
    --bg-glass: rgba(13, 17, 23, 0.7); /* Kính đen mờ */
    --border-color: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.05);
    --text-primary: #e2e8f0;
    --text-muted: #64748b;
    --text-main: #e2e8f0;
    --text-dim: #e2e8f0;     
    --color-green: #0ecb81;
    --color-red: #ff6575;
    --color-yellow: #ffd043; 
    --accent: #ffd043;               /* Vàng PICOQUANT */
    --accent-gold: #ffd043;
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* --- 2. BASE RESETS & BODY --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    background-color: var(--bg-deep) !important;
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100%;
    min-height: 100vh !important;
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* TICKER TAPE ANIMATION (GLOBAL) */
.ticker-tape-container { 
    display: flex; 
    align-items: center; 
}
.ticker-tape { 
    display: inline-flex; 
    animation: ticker-scroll 120s linear infinite; 
}
.ticker-tape:hover { 
    animation-play-state: paused; 
}
@keyframes ticker-scroll { 
    0% { transform: translateX(0); } 
    100% { transform: translateX(-50%); } 
}
.ticker-item { 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    padding: 0 16px; 
    border-right: 0px solid rgba(255,255,255,0.1); 
}
.ticker-item:last-child { 
    border-right: none; 
}
.ticker-sym { 
    font-weight: 700; 
    color: #fff; 
    font-size: 13px; 
}
.ticker-price { 
    color: var(--text-muted); 
    font-size: 13px; 
}
.ticker-change { 
    font-size: 12px; 
    font-weight: 700; 
}
.ticker-change.green { color: var(--color-green); }
.ticker-change.red { color: var(--color-red); }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-main);
    flex-direction: column !important;
    overflow-y: auto;
    letter-spacing: -0.2px;
    width: 100% !important;
    margin: 0 auto !important;
    height: 100%;
    padding-top: 40px !important;    /* NHƯỜNG 78PX CHO HEADER + TICKER FIXED */
    padding-bottom: 48px !important; /* NHƯỜNG 42PX CHO FOOTER FIXED */
    display: flex !important;
    min-height: 100vh !important;
    overflow-x: clip !important;
}

/* --- 3. HEADER FIXED (70PX) --- */
header, .app-header {
    height: 48px !important;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10000 !important;
    width: 100%;
    box-sizing: border-box;
}

.brand {
    font-size: 14px;
    font-weight: 800;
    color: var(--color-yellow);
    display: flex;
    align-items: center;
    gap: 4px;
}

.engine-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 500; 
}

/* --- 4. FOOTER FIXED (42PX) --- */
footer { 
    width: 100% !important; 
    position: fixed !important;
    bottom: 0 !important; 
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    height: 42px !important;
    border-top: 1px solid var(--border-color) !important;
    background: var(--bg-panel) !important; 
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
    margin-top: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
}

/* --- 5. AD BANNER SLOT (120x60) --- */
.ad-banner-slot {
    width: 120px;
    height: 60px;
    min-width: 120px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    overflow: hidden;
    box-sizing: border-box;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- 6. LAYOUT WRAPPER & WORKSPACE CONTAINER --- */
main {
    display: block;
    width: 100%;
    flex: 1 0 auto !important;
}

.workspace {
    display: flex;
    flex: 1 0 auto !important;
    flex-direction: column;
    gap: 8px;
    padding: 6px 4px;
    width: 100%;
    margin: 0 auto;
    flex-shrink: 0;
    box-sizing: border-box;
}

#view-live.workspace {
    padding-top: 0px !important;
}

.main-workspace-content,
.workspace,
main {
    flex: 1 0 auto !important;
    overflow: visible !important;
}

.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: visible !important;
}

.panel-header {
    padding: 1px 14px;
    background-color: var(--bg-header); 
    border-bottom: 1px solid var(--border-color); 
    font-size: 11px; 
    font-weight: 600; 
    color: var(--text-primary); 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}

/* --- 7. FLOATING SIDEBAR --- */
.layout-wrapper {
    position: relative !important;
    display: flex !important;
    width: 100% !important;
    margin: 0 auto !important;
    min-height: auto !important;
}

.floating-sidebar {
    position: fixed !important;
    left: 12px !important;
    top: 46px !important;    /* Header + Ticker 78px + 8px gap */
    bottom: 50px !important; /* Footer 42px + 8px gap */
    width: 60px !important;
    background: rgba(12, 14, 18, 0.92) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    height: auto !important;
    max-height: calc(100vh - 156px) !important;
    z-index: 9999 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s, border-color 0.25s !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.floating-sidebar:hover {
    width: 245px !important;
    border-color: rgba(255, 208, 67, 0.3) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.95) !important;
}

.sidebar-inner-container {
    display: flex !important; flex-direction: column;
    justify-content: space-between;
    height: 100%;
    width: 245px;
    padding: 16px 8px;
    box-sizing: border-box;
}

.sidebar-section-title {
    font-size: 9px !important;
    color: #475569 !important;
    font-weight: 700 !important;
    padding-left: 14px !important;
    margin-bottom: 6px !important;
    letter-spacing: 0.8px !important;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.floating-sidebar:hover .sidebar-section-title { opacity: 1 !important; }

.sidebar-btn {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: #cbd5e1 !important;
    padding: 10px 0 !important;
    border-radius: 6px !important;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.sidebar-btn .icon {
    min-width: 42px !important;
    width: 42px !important;
    font-size: 14px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    opacity: 0.8;
}

.sidebar-btn .icon svg {
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-btn:hover .icon,
.sidebar-btn.active .icon {
    opacity: 1 !important;
}

.sidebar-btn .label {
    font-size: 11.5px !important;
    font-weight: 600 !important;
    opacity: 0 !important;
    transform: translateX(-5px) !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
    color: #cbd5e1 !important;
}

.floating-sidebar:hover .sidebar-btn .label {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

.sidebar-btn:hover { background-color: rgba(255, 255, 255, 0.06) !important; color: #fff !important; }
.sidebar-btn.active { 
    background-color: rgba(255, 255, 255, 0.03) !important; 
    border-color: var(--glass-border, rgba(255, 255, 255, 0.1)) !important; 
    color: #cbd5e1 !important; 
}
.sidebar-btn.active .label { color: #cbd5e1 !important; }

.main-workspace-content {
    flex: 1;
    min-width: 0;
    background-color: var(--bg-main);
    overflow-y: auto;
    padding-left: 85px !important;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.layout-wrapper:has(.floating-sidebar:hover) .main-workspace-content {
    filter: blur(3px) brightness(50%) !important;
    opacity: 0.4;
    pointer-events: none;
}

/* --- 8. AUTHENTICATION & MODAL POPUPS --- */
.login-wrapper { 
  min-height: 100vh; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  background-color: var(--bg-main); 
  margin: 0;
}

.login-box, .password-box { 
  width: 100%; 
  max-width: 400px; 
  padding: 30px; 
  background-color: var(--bg-panel); 
  border: 1px solid var(--border-color); 
  border-radius: 8px; 
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); 
  text-align: center;
}

.form-group { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  margin-bottom: 20px; 
  text-align: left; 
}

.form-group label { 
  font-size: 11px; 
  color: var(--text-muted); 
  font-weight: 600; 
  text-transform: uppercase; 
}

.form-group input, .password-box input { 
  background-color: var(--bg-main); 
  border: 1px solid var(--border-color); 
  color: var(--text-primary); 
  padding: 14px; 
  border-radius: 4px; 
  font-size: 14px; 
  outline: none; 
  transition: 0.2s; 
  box-sizing: border-box; 
  width: 100%; 
}

.form-group input:focus, .password-box input:focus { border-color: var(--color-yellow); }

.btn-auth, .password-box button { 
  width: 100%; 
  background-color: var(--color-yellow); 
  color: #000; 
  border: none; 
  padding: 14px; 
  border-radius: 4px; 
  font-weight: 700; 
  font-size: 14px; 
  cursor: pointer; 
  transition: 0.2s; 
  text-transform: uppercase; 
}

.btn-auth:hover, .password-box button:hover { opacity: 0.9; }

.error-alert { 
  background-color: rgba(255, 101, 117, 0.1); 
  border: 1px solid var(--color-red); 
  color: var(--color-red); 
  padding: 12px; 
  border-radius: 4px; 
  font-size: 13px; 
  margin-bottom: 20px; 
  text-align: center; 
  font-weight: 600; 
}

.success-alert { 
  background-color: rgba(14, 203, 129, 0.1); 
  border: 1px solid var(--color-green); 
  color: var(--color-green); 
  padding: 12px; 
  border-radius: 4px; 
  font-size: 13px; 
  margin-bottom: 20px; 
  text-align: center; 
  font-weight: 600; 
}

/* --- 9. UTILITY CLASSES --- */
.green { color: var(--color-green) !important; } 
.red { color: var(--color-red) !important; } 
.yellow { color: var(--color-yellow) !important; }
.white { color: white !important; }
.purple { color: #d845e8 !important; }
.di-doi-col { color: #5e6673 !important; }

.badge { padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: 700; display: inline-block; }
.badge.new { background: rgba(255, 208, 67, 0.15); color: var(--color-yellow); }
.badge.filled { background: rgba(14, 203, 129, 0.15); color: var(--color-green); }
.badge.canceled { background: rgba(255, 101, 117, 0.15); color: var(--color-red); }

.autocomplete-wrapper { position: relative; display: inline-block; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; z-index: 1000;
    background: rgba(13, 17, 23, 0.95) !important; border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.05)) !important; border-radius: 8px !important;
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    width: 250px; max-height: 200px; overflow-y: auto;
    list-style: none; padding: 4px 0; margin: 4px 0 0 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6); display: none;
}
.autocomplete-list li {
    padding: 6px 12px; font-size: 11.5px; color: var(--text-primary); font-weight: 500;
    cursor: pointer;
}
.autocomplete-list li:hover { background-color: rgba(255, 255, 255, 0.08) !important; color: var(--text-primary); }

.switch-container { display: flex; align-items: center; gap: 6px; margin-left: 6px; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255, 255, 255, 0.03); transition: .3s; border-radius: 20px; border: 1px solid var(--glass-border); }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 1px; background-color: var(--text-muted, #787b86); transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: rgba(2, 192, 118, 0.15); border-color: var(--color-green, #02c076); }
input:checked + .slider:before { transform: translateX(16px); background-color: var(--color-green, #02c076); }

/* --- ĐÈN BÁO TRẠNG THÁI HỆ THỐNG --- */
.pulse-dot {
    width: 7px !important;
    height: 7px !important;
    min-width: 7px !important;
    min-height: 7px !important;
    border-radius: 50% !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.4);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.heartbeat-green {
    animation: heartbeat 1.8s infinite ease-in-out !important;
}

/* --- 10. NEW MODERN GLASS CLASSES --- */
.premium-glass-panel {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px;
    margin: 6px 4px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.glass-input {
    background: rgba(13, 17, 23, 0.95) !important;
    border: 1px solid var(--glass-border) !important;
    color: #fff !important;
    border-radius: 8px !important;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.3s;
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
}

.glass-input:focus {
    border-color: var(--glass-border) !important;
}

.btn-premium-action {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-premium-action:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 20px rgba(255, 208, 67, 0.4);
    transform: translateY(-2px);
}

.risk-grid-modern {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 1px; /* Tạo đường chia mảnh */
    background: var(--glass-border); /* Màu đường chia */
}

@media (max-width: 1023px) and (min-width: 624px) {
    .risk-grid-modern { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}

@media (max-width: 623px) {
    .risk-grid-modern { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 6px !important; background: transparent; }
}

.risk-card-modern {
    background: var(--bg-glass);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative !important;
    overflow: visible !important;
}

.risk-card-modern .label {
    color: var(--text-muted);
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 700;
}

.risk-card-modern .value {
    font-size: 12px;
    font-weight: 500; /* Giảm độ đậm từ 800 xuống 500 để chữ thanh thoát hơn */
    letter-spacing: 0.5px; /* Thêm chút khoảng cách để số dễ đọc hơn */
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; /* Ưu tiên font Inter hiện đại */
}

.glass-slider {
    -webkit-appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.glass-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent);
}
.white { color: white !important; }
.purple { color: #d845e8 !important; }
.emoji-mono { filter: grayscale(100%) opacity(0.7) contrast(1.2); mix-blend-mode: luminosity; }

/* --- GLOBAL SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 123, 134, 0.4); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 123, 134, 0.8); }
* { scrollbar-width: thin; scrollbar-color: rgba(120, 123, 134, 0.4) transparent; }

/* --- 11. MOBILE SPACE OPTIMIZATIONS --- */
@media (max-width: 624px) {
    .workspace {
        padding: 2px 2px !important;
    }
    .premium-glass-panel {
        margin: 2px 2px !important;
        border-radius: 8px !important;
    }
    .panel-header {
        padding: 8px 8px !important;
    }
    .floating-sidebar {
        left: 1px !important;
        width: 44px !important;
    }
    .floating-sidebar .sidebar-btn {
        padding: 4px 0 !important;
    }
    .floating-sidebar .sidebar-inner-container {
        padding: 16px 0 !important;
    }
    .floating-sidebar .sidebar-btn .icon {
        min-width: 44px !important;
    }
    .main-workspace-content {
        padding-left: 44px !important;
    }
    .panel-orders, .panel-matrix {
        padding: 2px !important;
    }
}