@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;800;900&display=swap');

:root {
    --bg-gradient: linear-gradient(180deg, #ffeaa7 0%, #fab1a0 100%);
    --card-bg: #ffffff;
    --primary: #fd79a8;
    --primary-dark: #e84393;
    --pink: #fd79a8;
    --pink-dark: #e84393;
    --green: #55efc4;
    --green-dark: #00b894;
    --blue: #74b9ff;
    --blue-dark: #0984e3;
    --purple: #a29bfe;
    --purple-dark: #6c5ce7;
    --wood-light: #ffeaa7;
    --wood-dark: #d63031;
    --text-main: #2d3436;
    --text-muted: #636e72;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Nunito', sans-serif; -webkit-tap-highlight-color: transparent;}
html, body { width: 100%; height: 100%; overflow: hidden; margin: 0; padding: 0; touch-action: manipulation; }
body { background: var(--bg-gradient); display: flex; justify-content: center; color: var(--text-main); }

/* Đồi cỏ nền mờ / Backdrop đổi thành cánh đồng hoa hồng */
.background-overlay { 
    position: fixed; bottom: 0; left: 0; width: 100%; height: 35%; 
    background: radial-gradient(ellipse at top, #ffb8b8 0%, #ff7675 100%);
    border-radius: 50% 50% 0 0 / 15% 15% 0 0; opacity: 0.4; z-index: 0; pointer-events: none;
}

.app-container { 
    width: 100%; max-width: 480px; height: 100%; position: relative; display: flex; flex-direction: column; 
    z-index: 1; background: rgba(255,255,255,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 0 40px rgba(0,0,0,0.15); 
}

/* ================= LOADER ================= */
#app-loader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #fd79a8; z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center; transition: opacity 0.5s ease; }
.loader-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-image: radial-gradient(circle at center, #ff9ff3 0%, #f368e0 100%); z-index: 1; }
.loader-content { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.loader-egg { font-size: 55px; animation: bounce 1s infinite alternate cubic-bezier(0.5, 0.05, 1, 0.5); margin-bottom: 15px;}
.loader-text { color: #fff; font-size: 18px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 4px 10px rgba(0,0,0,0.6); }
.loader-bar { width: 200px; height: 14px; background: rgba(0,0,0,0.2); border-radius: 10px; margin-top: 15px; overflow: hidden; position: relative; border: 2px solid #fff; box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);}
.loader-bar-fill { position: absolute; top: 0; left: 0; height: 100%; width: 0%; background: #fff; border-radius: 10px; animation: fillBar 2.5s ease-out forwards; }

@keyframes fillBar { to { width: 100%; } }

/* --- HEADER & ASSETS --- */
.main-header { padding: 15px 20px; z-index: 10; position: relative;}
.user-bar { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 8px 15px; border-radius: 50px; box-shadow: 0 6px 15px rgba(253, 121, 168, 0.15); border: 3px solid #ffeaa7;}
.user-profile { display: flex; align-items: center; gap: 10px; }
.avatar { width: 42px; height: 42px; background: var(--bg-gradient); border-radius: 50%; display: flex; justify-content: center; align-items: center; border: 2px solid var(--primary); overflow: hidden;}
.username { font-weight: 900; font-size: 15px; color: var(--wood-dark); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.badge-admin { background: var(--pink-dark); color: #fff; font-size: 9px; padding: 3px 8px; border-radius: 10px; margin-left: 5px;}
.status-dot { width: 10px; height: 10px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite;}

@keyframes pulse { 0% { transform: scale(0.95); opacity: 0.8; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(0.95); opacity: 0.8; } }

.assets-panel { display: flex; gap: 8px; margin-top: 15px;}
.asset-item { flex: 1; background: linear-gradient(180deg, #ffffff 0%, #fff0f5 100%); padding: 10px 5px; border-radius: 18px; box-shadow: 0 6px 0 #fad390; text-align: center; border: 2px solid #fff; display: flex; flex-direction: column; align-items: center; }
.asset-icon { font-size: 20px; margin-bottom: 2px; filter: drop-shadow(0 2px 2px rgba(253, 121, 168, 0.2));}
.asset-value { font-size: 14px; font-weight: 900; color: var(--text-main); white-space: nowrap;}
.asset-label { font-size: 10px; font-weight: 800; color: var(--text-muted); text-transform: uppercase;}

/* --- CONTENT AREA & CARDS --- */
.content-area { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 20px 120px 20px; -webkit-overflow-scrolling: touch; }
.content-area::-webkit-scrollbar { display: none; }
.view { display: none; animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.view.active { display: block; }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.95) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

.card { background: rgba(255,255,255,0.9); border-radius: 24px; padding: 20px; margin-bottom: 20px; border: 3px solid rgba(253, 121, 168, 0.3); box-shadow: 0 10px 25px rgba(253, 121, 168, 0.1); }
.card-title { font-size: 18px; font-weight: 900; color: var(--wood-dark); display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; text-transform: uppercase;}
.badge-status { background: var(--pink); color: #fff; font-size: 11px; padding: 6px 14px; border-radius: 20px; font-weight: 900; box-shadow: 0 4px 10px rgba(253, 121, 168, 0.4);}
.section-title { font-size: 16px; font-weight: 900; text-align: center; margin: 10px 0 15px 0; color: var(--pink-dark); background: #fff; display: inline-block; padding: 6px 20px; border-radius: 20px; border: 2px solid #fad390; box-shadow: 0 4px 0 #fad390; left: 50%; transform: translateX(-50%); position: relative; text-transform: uppercase;}

.action-buttons { display: flex; gap: 15px; position: relative; z-index: 20;}
.btn { border: none; outline: none; border-radius: 18px; font-weight: 900; font-size: 15px; cursor: pointer; padding: 14px 15px; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.1s; color: white; border: 2px solid rgba(255,255,255,0.6); text-shadow: 0 2px 2px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(6px); box-shadow: 0 0 0 transparent !important; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none !important; filter: grayscale(100%);}
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); box-shadow: 0 6px 0 #b8326a;}
.btn-pink { background: linear-gradient(180deg, #ff9ff3, #f368e0); box-shadow: 0 6px 0 #b33771;}
.btn-green { background: linear-gradient(180deg, var(--green), var(--green-dark)); box-shadow: 0 6px 0 #008f73;}
.btn-blue { background: linear-gradient(180deg, var(--blue), var(--blue-dark)); box-shadow: 0 6px 0 #0762a8;}
.btn-purple { background: linear-gradient(180deg, var(--purple), var(--purple-dark)); box-shadow: 0 6px 0 #4f41a8;}
.btn-outline { background: #fff; color: var(--text-muted); border: 2px solid #fad390; box-shadow: 0 4px 0 #fad390; text-shadow: none;}
.w-100 { width: 100%; }

/* ================= TRẠNG TRẠI / NHÀ MÁY SIÊU RỘNG (100 SLOT/LOẠI) ================= */
.chicken-stage-container { 
    position: relative; width: 100%; height: 380px; 
    background: radial-gradient(circle at top, #ffeaa7 0%, #fab1a0 100%);
    border-radius: 20px; border: 4px solid #e17055; 
    box-shadow: inset 0 10px 30px rgba(0,0,0,0.1), 0 8px 15px rgba(253, 121, 168, 0.2); 
    margin-bottom: 20px; display: flex; flex-direction: column; overflow: hidden;
}
.swipe-hint {
    text-align: center; font-size: 11px; font-weight: 900; color: #d63031;
    text-transform: uppercase; padding: 6px 0; background: rgba(255, 255, 255, 0.6); z-index: 10;
    border-bottom: 2px solid rgba(225, 112, 85, 0.3);
}
.farm-zones-wrapper {
    flex: 1; display: flex; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; padding: 15px 0; scroll-behavior: smooth;
}
.farm-zones-wrapper::-webkit-scrollbar { display: none; } 

.farm-zone {
    flex: 0 0 100%; scroll-snap-align: center; padding: 0 15px; 
    height: 100%; overflow-y: auto; 
}
.farm-zone::-webkit-scrollbar { width: 4px; }
.farm-zone::-webkit-scrollbar-thumb { background: rgba(253, 121, 168, 0.5); border-radius: 4px; }

.zone-title {
    text-align: center; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    font-weight: 900; font-size: 15px; margin-bottom: 12px;
    background: rgba(253, 121, 168, 0.8); border-radius: 12px; padding: 6px; border: 1px solid rgba(255,255,255,0.5);
}

.zone-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding-bottom: 15px;
}

/* Slot chứa Máy in */
.slot {
    aspect-ratio: 1; background: rgba(255, 255, 255, 0.4); border-radius: 12px;
    border: 2px dashed rgba(253, 121, 168, 0.5); display: flex;
    align-items: center; justify-content: center; overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(253, 121, 168, 0.2);
}
.slot.filled { border: 2px solid rgba(253, 121, 168, 0.8); background: rgba(255, 255, 255, 0.8); }

/* Máy in (Active Anim) */
.active-anim {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    border-radius: 10px; text-shadow: 0 4px 8px rgba(0,0,0,0.1);
    animation: breathe 2s infinite alternate ease-in-out;
}

/* Trạng thái */
.ready .farm-zones-wrapper { filter: brightness(0.8) hue-rotate(-20deg); }
.ready .active-anim { animation: none !important; transform: scaleY(0.9) translateY(4px) !important; color: #b2bec3 !important; }

/* Nhảy */
.active-anim.jumping { animation: jumpAct 0.8s ease-in-out !important; }

@keyframes breathe { 0% { transform: scaleY(1) translateY(0); } 100% { transform: scaleY(0.96) translateY(2px); filter: drop-shadow(0 0 5px currentColor); } }
@keyframes jumpAct { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
@keyframes bounce { 0% { transform: translateY(0); } 100% { transform: translateY(15px); } }

/* --- CÁC THÀNH PHẦN GIAO DIỆN KHÁC --- */
.capacity-info { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 15px; border-radius: 16px; border: 2px dashed var(--pink); margin-bottom: 15px;}
.capacity-info strong { font-size: 24px; color: var(--pink-dark); font-weight: 900;}

.shop-item { display: flex; align-items: center; background: #fff; padding: 15px; border-radius: 20px; margin-bottom: 15px; border: 2px solid #fad390; box-shadow: 0 4px 10px rgba(253, 121, 168, 0.1);}
.shop-icon { width: 65px; height: 65px; display: flex; justify-content: center; align-items: center; border-radius: 18px; box-shadow: 0 4px 10px rgba(253, 121, 168, 0.2); padding: 0; overflow: hidden; background: #fff0f5;}
.shop-info { flex: 1; padding-left: 15px; }
.shop-info h4 { font-weight: 900; font-size: 16px; color: var(--pink-dark); margin-bottom: 3px;}

.input-group { margin-top: 15px; }
.input-group label { font-size: 12px; font-weight: 900; color: var(--pink-dark); text-transform: uppercase; margin-bottom: 5px; display: block;}
.input-with-icon { position: relative; display: flex; align-items: center;}
.input-with-icon input, .input-with-icon select, .admin-input, .admin-select, .admin-textarea { width: 100%; background: #fff; border: 2px solid #fad390; padding: 15px 45px 15px 15px; border-radius: 16px; font-weight: 800; font-size: 15px; outline: none; transition: 0.2s; color: var(--text-main);}
.input-with-icon input:focus, .input-with-icon select:focus, .admin-input:focus { border-color: var(--pink); background: #fff0f5;}
.input-with-icon .icon { position: absolute; right: 15px; font-size: 18px; color: var(--pink);}

.exchange-rate-box { background: rgba(253, 121, 168, 0.1); border: 2px dashed var(--pink); border-radius: 20px; padding: 15px; text-align: center; margin-bottom: 15px;}
.rate-item { font-size: 16px; font-weight: 900;}

.history-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;}
.history-item, .lb-item { background: #fff; border: 2px solid #fad390; border-radius: 16px; padding: 15px; display: flex; justify-content: space-between; align-items: center;}
.lb-rank { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 16px;}
.rank-1 { background: linear-gradient(135deg, #f1c40f, #f39c12); color: #fff; box-shadow: 0 4px 0 #d35400;}
.rank-2 { background: linear-gradient(135deg, #bdc3c7, #95a5a6); color: #fff; box-shadow: 0 4px 0 #7f8fa6;}
.rank-3 { background: linear-gradient(135deg, #e67e22, #d35400); color: #fff; box-shadow: 0 4px 0 #a83200;}

/* ================= MENU BOTTOM ================= */
.bottom-nav-container { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 440px; z-index: 1000; pointer-events: none; }
.side-menu { position: absolute; bottom: 85px; right: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border: 3px solid #fad390; border-radius: 24px; padding: 12px; box-shadow: 0 10px 30px rgba(253, 121, 168, 0.2); width: 180px; display: flex; flex-direction: column; gap: 6px; transform: scale(0.8) translateY(20px); opacity: 0; pointer-events: none; transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-origin: bottom right; }
.side-menu.show { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }
.side-nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-radius: 16px; text-decoration: none; color: var(--text-main); font-weight: 800; font-size: 14px; transition: 0.2s; }
.side-nav-item i { font-size: 18px; color: var(--pink); width: 24px; text-align: center;}
.side-nav-item:active, .side-nav-item.active { background: rgba(253, 121, 168, 0.1); color: var(--pink-dark);}
.side-nav-item:active i, .side-nav-item.active i { color: var(--primary-dark);}

.bottom-nav { display: flex; justify-content: space-between; align-items: center; pointer-events: auto; background: rgba(255,255,255,0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 3px solid #fad390; box-shadow: 0 10px 30px rgba(253, 121, 168, 0.15); padding: 10px 15px; border-radius: 35px; width: 100%; }
.main-nav-item, .menu-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--pink); text-decoration: none; font-weight: 800; transition: 0.3s; flex: 1; cursor: pointer; }
.main-nav-item i, .menu-toggle i { font-size: 22px; margin-bottom: 4px; transition: 0.3s;}
.main-nav-item span, .menu-toggle span { font-size: 10px; text-transform: uppercase;}
.main-nav-item.active, .menu-toggle.active { color: var(--pink-dark); transform: translateY(-4px);}
.main-nav-item.active i, .menu-toggle.active i { color: var(--primary-dark); transform: scale(1.1);}

.system-notice-bar { background: linear-gradient(90deg, #ff9ff3, #feca57); color: #fff; padding: 12px 20px; font-size: 14px; font-weight: 900; display: flex; align-items: center; border-radius: 16px; margin-bottom: 15px; box-shadow: 0 4px 15px rgba(254, 202, 87, 0.4); border: 2px solid #fff; }
.notice-icon { margin-right: 15px; font-size: 18px; animation: bell-ring 2s infinite; }
.notice-text-container { flex: 1; overflow: hidden; position: relative; white-space: nowrap; }
.notice-scroll { display: inline-block; padding-left: 100%; animation: marquee 10s linear infinite; text-shadow: 1px 1px 2px rgba(0,0,0,0.1);}
@keyframes marquee { 0% { transform: translate3d(0, 0, 0); } 100% { transform: translate3d(-100%, 0, 0); } }

/* ADMIN */
.admin-card { background: #fff; border-radius: 24px; padding: 25px 20px; margin-bottom: 25px; box-shadow: 0 6px 20px rgba(253, 121, 168, 0.1); border: 2px solid #fad390;}
.admin-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.admin-stat-box { background: #fff0f5; padding: 15px 5px; border-radius: 16px; text-align: center; border: 1px solid #fad390;}
.hidden { display: none !important; }
