:root {
    --bg-color: #121212;
    --top-bar-bg: #1f1f1f;
    --text-color: #ffffff;
    --card-bg: #1c1c1c;
    --btn-bg: #323232;
    --btn-hover: #3b3b3b;
    --accent: #0067c0;
    --input-bg: #2a2a2a;
    --sidebar-bg: #181818;
    --shadow: 0 10px 30px rgba(0,0,0,0.3);
    --sidebar-width: 320px;
}

.light-mode {
    --bg-color: #f3f3f3;
    --top-bar-bg: #ffffff;
    --text-color: #1a1a1a;
    --card-bg: #ffffff;
    --btn-bg: #e6e6e6;
    --btn-hover: #dcdcdc;
    --accent: #0067c0;
    --input-bg: #ffffff;
    --sidebar-bg: #e0e0e0;
    --shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* الأساسيات */
* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* شريط التنقل */
.top-bar {
    background-color: var(--top-bar-bg);
    min-height: 65px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.top-bar-right { flex: 0 0 auto; }
.top-bar-center { flex: 1; display: flex; justify-content: center; gap: 15px; }
.top-bar-left { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }

.site-logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    transition: 0.2s;
    opacity: 0.8;
}

.nav-links a:hover { opacity: 1; background: rgba(128,128,128,0.1); }
.nav-links a.active { background: var(--accent); color: white; opacity: 1; }

.lang-switcher {
    background: var(--btn-bg);
    color: var(--text-color);
    border: 1px solid rgba(128,128,128,0.2);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    outline: none;
}

.theme-toggle {
    background: var(--btn-bg);
    border: 1px solid rgba(128,128,128,0.2);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.theme-toggle:hover { transform: rotate(15deg); background: var(--btn-hover); }

/* التخطيط الرئيسي */
.layout-wrapper {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

/* الجوانب للموازنة */
.sidebar-history, .sidebar-spacer {
    width: var(--sidebar-width);
    flex-shrink: 0;
}

.sidebar-history {
    background-color: var(--sidebar-bg);
    border-inline-end: 1px solid rgba(128,128,128,0.1);
    display: flex;
    flex-direction: column;
}

.history-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(128,128,128,0.05);
}

.history-header span { font-weight: bold; font-size: 18px; }

.clear-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    transition: 0.2s;
}

.clear-btn:hover { background: rgba(0,103,192,0.1); }

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    text-align: end;
    border: 1px solid rgba(128,128,128,0.05);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.no-history-msg { text-align: center; opacity: 0.4; margin-top: 40px; }

/* المحتوى المركزي */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 40px 20px;
}

.page-section {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
}

/* بطاقة الحاسبة */
.calculator-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: 30px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(128,128,128,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    direction: ltr;
}

.std-calculator { max-width: 420px; }
.prac-calculator { max-width: 620px; }

.calc-header {
    padding: 12px 20px;
    background: rgba(0,0,0,0.1);
    font-size: 13px;
    opacity: 0.7;
    text-align: center;
}

.display-area {
    padding: 30px;
    background: rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-height: 160px;
}

.equation-line { font-size: 18px; opacity: 0.5; min-height: 24px; margin-bottom: 8px; }
.main-value { font-size: 48px; font-weight: 300; word-break: break-all; line-height: 1.1; }

.buttons-grid { display: grid; gap: 10px; padding: 20px; }
.std-grid { grid-template-columns: repeat(4, 1fr); }
.prac-grid { grid-template-columns: repeat(6, 1fr); }

button {
    border: none;
    background: var(--btn-bg);
    color: var(--text-color);
    padding: 18px 0;
    font-size: 20px;
    font-weight: 500;
    border-radius: 15px;
    cursor: pointer;
    transition: 0.2s;
}

button:hover { background: var(--btn-hover); transform: translateY(-1px); }
button:active, button.kb-active { background: var(--accent) !important; color: white !important; transform: scale(0.95); }

.btn-num { font-weight: 600; }
.btn-clear { color: #ff4444; }
.btn-equals { background: var(--accent) !important; color: white !important; font-weight: bold; }
.btn-equals-large { grid-row: span 2; background: var(--accent) !important; color: white !important; font-size: 30px; }

/* بطاقة BMI */
.bmi-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 30px;
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(128,128,128,0.1);
}

.bmi-title { color: #b8860b; text-align: center; margin-bottom: 30px; font-size: 28px; }

.bmi-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-group label { font-size: 14px; opacity: 0.8; font-weight: 600; }
.input-group input {
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(128,128,128,0.2);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 18px;
    text-align: center;
    outline: none;
}

.action-btn {
    width: 100%;
    background: var(--accent);
    color: white;
    padding: 15px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
}

.bmi-status { margin-top: 20px; text-align: center; font-size: 22px; font-weight: bold; color: var(--accent); }

/* بطاقة حول الموقع */
.about-card {
    background: var(--card-bg);
    padding: 50px;
    border-radius: 35px;
    width: 100%;
    max-width: 800px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(128,128,128,0.1);
}

.about-card h2 { color: var(--accent); font-size: 32px; margin-bottom: 25px; text-align: center; }
.about-text { line-height: 1.8; font-size: 18px; text-align: justify; opacity: 0.9; }

/* شاشات الجوال */
@media (max-width: 1000px) {
    .sidebar-spacer { display: none; }
    .layout-wrapper { flex-direction: column; overflow-y: auto; }
    .sidebar-history { width: 100%; border-inline-end: none; border-top: 1px solid rgba(128,128,128,0.1); order: 2; }
    .main-content { order: 1; padding: 20px; }
    .top-bar { flex-direction: column; height: auto; padding: 15px; gap: 15px; }
    .top-bar-center { order: 3; width: 100%; flex-wrap: wrap; }
}