:root {
    --bg: #121212; --top: #1f1f1f; --text: #ffffff;
    --card: #1c1c1c; --btn: #323232; --hover: #3b3b3b;
    --accent: #0067c0; --input: #2a2a2a; --side: #181818;
    --side-w: 320px;
}
.light-mode {
    --bg: #f3f3f3; --top: #ffffff; --text: #1a1a1a;
    --card: #ffffff; --btn: #e6e6e6; --hover: #dcdcdc;
    --accent: #0067c0; --input: #ffffff; --side: #e0e0e0;
}

/* تصفير وحماية */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, sans-serif; overflow: hidden; }

#app-container { display: flex; flex-direction: column; height: 100vh; width: 100vw; }

/* الهيدر */
.site-header { 
    background: var(--top); height: 65px; display: flex; align-items: center; 
    padding: 0 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); z-index: 100;
}
.header-right { flex: 0 0 200px; }
.header-center { flex: 1; display: flex; justify-content: center; }
.header-left { flex: 0 0 200px; display: flex; justify-content: flex-end; gap: 10px; }

.brand-logo { font-size: 24px; font-weight: 900; color: var(--accent); text-decoration: none; }
.nav-menu { display: flex; gap: 10px; }
.nav-item { color: var(--text); text-decoration: none; padding: 8px 15px; border-radius: 8px; font-weight: 600; opacity: 0.7; transition: 0.2s; }
.nav-item.active { background: var(--accent); color: white; opacity: 1; }
.nav-item:hover { opacity: 1; background: rgba(128,128,128,0.1); }

.language-select { background: var(--btn); color: var(--text); border: 1px solid rgba(128,128,128,0.2); padding: 5px 10px; border-radius: 6px; outline: none; }
.theme-btn { background: var(--btn); border: 1px solid rgba(128,128,128,0.2); color: var(--text); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* التخطيط */
.app-layout { display: flex; flex: 1; overflow: hidden; }
.app-sidebar, .app-spacer { width: var(--side-w); flex-shrink: 0; }

.app-sidebar { background: var(--side); border-inline-end: 1px solid rgba(128,128,128,0.1); display: flex; flex-direction: column; }
.sidebar-top { padding: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(128,128,128,0.05); font-weight: bold; }
.btn-text-action { background: none; border: none; color: var(--accent); cursor: pointer; font-weight: bold; }

.history-container { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.history-item { background: var(--card); padding: 15px; border-radius: 12px; text-align: end; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.empty-history { text-align: center; opacity: 0.4; margin-top: 30px; }

.app-main { flex: 1; overflow-y: auto; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; }
.content-page { width: 100%; display: flex; justify-content: center; align-items: center; min-height: 100%; }

/* الحاسبة */
.calc-box { width: 100%; background: var(--card); border-radius: 25px; box-shadow: 0 15px 40px rgba(0,0,0,0.3); border: 1px solid rgba(128,128,128,0.1); overflow: hidden; direction: ltr; }
.std-box { max-width: 400px; }
.prac-box { max-width: 600px; }

.calc-label { padding: 10px; background: rgba(0,0,0,0.05); text-align: center; font-size: 12px; opacity: 0.6; }
.calc-screen { padding: 25px; background: rgba(0,0,0,0.03); display: flex; flex-direction: column; align-items: flex-end; min-height: 140px; }
.screen-eq { font-size: 16px; opacity: 0.5; min-height: 20px; margin-bottom: 5px; }
.screen-main { font-size: 44px; font-weight: 300; word-break: break-all; }

.calc-buttons { display: grid; gap: 8px; padding: 15px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

button { border: none; background: var(--btn); color: var(--text); padding: 18px 0; font-size: 20px; border-radius: 12px; cursor: pointer; transition: 0.15s; font-weight: 500; }
button:hover { background: var(--hover); transform: translateY(-1px); }
button:active, button.kb-active { background: var(--accent) !important; color: white !important; transform: scale(0.95); }

.btn-digit { font-weight: 700; }
.btn-danger { color: #ff4d4d; }
.btn-primary { background: var(--accent) !important; color: white !important; font-weight: bold; }
.btn-primary-large { grid-row: span 2; background: var(--accent) !important; color: white !important; font-size: 28px; }

/* البطاقات المعلوماتية */
.info-card { background: var(--card); padding: 40px; border-radius: 25px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.2); border: 1px solid rgba(128,128,128,0.1); }
.bmi-card-box { max-width: 550px; }
.about-card-box { max-width: 750px; }

h2 { color: var(--accent); text-align: center; margin-bottom: 25px; font-size: 28px; }
.bmi-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 15px; margin-bottom: 25px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; opacity: 0.8; font-weight: bold; }
.form-group input { padding: 12px; border-radius: 10px; border: 1px solid rgba(128,128,128,0.2); background: var(--input); color: var(--text); font-size: 18px; text-align: center; outline: none; }

.btn-submit { width: 100%; background: var(--accent); color: white; padding: 14px; border-radius: 10px; font-weight: bold; font-size: 18px; }
.bmi-status-text { margin-top: 15px; text-align: center; font-size: 20px; font-weight: bold; color: var(--accent); }
.rich-text { line-height: 1.8; font-size: 17px; text-align: justify; opacity: 0.9; }

/* الجوال */
@media (max-width: 1000px) {
    .app-spacer { display: none; }
    .app-layout { flex-direction: column; overflow-y: auto; }
    .app-sidebar { width: 100%; border-inline-end: none; border-top: 1px solid rgba(128,128,128,0.1); order: 2; }
    .app-main { order: 1; padding: 20px; overflow-y: visible; }
    .site-header { flex-direction: column; height: auto; padding: 15px; gap: 15px; }
    .header-right, .header-left { flex: 0 0 auto; width: 100%; justify-content: center; display: flex; }
    .header-center { width: 100%; }
    .nav-menu { flex-wrap: wrap; justify-content: center; }
}