:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #166534;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

[dir="rtl"] { font-family: 'Noto Sans Arabic', sans-serif; }

/* Header & Nav */
.main-header { background: white; padding: 1rem; text-align: center; border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.3rem; }
.blue-icon { width: 24px; height: 24px; background: var(--primary); border-radius: 6px; }

.lang-switcher-wrap { display: flex; justify-content: center; margin: 1.5rem 0; }
.lang-pill { background: white; border: 1px solid var(--border); border-radius: 50px; padding: 4px; display: flex; }
.lang-pill button { border: none; background: none; padding: 8px 20px; border-radius: 50px; cursor: pointer; font-weight: 600; color: var(--muted); transition: 0.3s; }
.lang-pill button.active { background: var(--primary); color: white; }

.tab-bar-wrap { display: flex; justify-content: center; margin-bottom: 2rem; overflow-x: auto; padding-bottom: 5px; }
.tab-bar { display: flex; gap: 5px; background: #e2e8f0; padding: 5px; border-radius: 12px; }
.tab-btn { border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; transition: 0.2s; }
.tab-btn.active { background: white; color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.page-intro { text-align: center; margin-bottom: 2.5rem; }
.page-intro h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.page-intro p { color: var(--muted); font-size: 1.1rem; }

.calculator-grid { display: grid; grid-template-columns: 1fr 450px; gap: 2rem; align-items: start; }

/* Cards */
.card { background: white; border: 1px solid var(--border); border-radius: 20px; padding: 2.5rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.02); }
.input-card h2 { font-size: 1.25rem; margin-bottom: 1.5rem; color: var(--primary); }

.input-group { margin-bottom: 1.2rem; }
label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
input, select { width: 100%; padding: 12px; border: 1.2px solid var(--border); border-radius: 10px; font-size: 1rem; outline: none; transition: border 0.3s; }
input:focus { border-color: var(--primary); }

.input-wrapper { position: relative; display: flex; align-items: center; }
.prefix { position: absolute; left: 12px; font-weight: 700; color: var(--muted); font-size: 0.8rem; }
[dir="rtl"] .prefix { left: auto; right: 12px; }

.input-wrapper input { padding-left: 45px; }
[dir="rtl"] .input-wrapper input { padding-left: 12px; padding-right: 45px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hint { font-size: 0.75rem; color: var(--muted); margin-top: 4px; display: block; }

.segmented-control { display: flex; background: var(--bg); padding: 4px; border-radius: 10px; gap: 4px; }
.segmented-control input { display: none; }
.segmented-control label { flex: 1; text-align: center; padding: 8px; border-radius: 7px; cursor: pointer; transition: 0.2s; font-weight: 600; }
.segmented-control input:checked + label { background: white; color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

.btn-primary { width: 100%; background: var(--primary); color: white; border: none; padding: 16px; border-radius: 12px; font-weight: 700; font-size: 1rem; cursor: pointer; transition: 0.2s; margin-top: 1rem; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); }

.privacy-note { text-align: center; font-size: 0.75rem; color: var(--muted); margin-top: 12px; }

/* Result Card */
.sticky { position: sticky; top: 20px; }
.res-placeholder { text-align: center; padding: 3rem 0; color: var(--muted); }
.total-display { font-size: 2.8rem; font-weight: 800; color: var(--primary); margin: 0.5rem 0; }
.badge { background: #dcfce7; color: var(--success); padding: 4px 12px; border-radius: 50px; font-size: 0.7rem; font-weight: 800; display: inline-block; }
.human-summary { background: #f1f5f9; padding: 1rem; border-radius: 12px; font-size: 0.9rem; margin-bottom: 1.5rem; color: var(--text); }

.employee-meta { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--border); }
.meta-item { font-size: 0.95rem; margin-bottom: 4px; }

.breakdown-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.breakdown-table th { text-align: left; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; padding: 8px 0; border-bottom: 1px solid var(--border); }
[dir="rtl"] .breakdown-table th { text-align: right; }

.breakdown-table td { padding: 12px 0; border-bottom: 1px solid #f8fafc; font-size: 0.95rem; }
.total-row td { border-bottom: none; padding-top: 15px; font-size: 1.1rem; }

.legal-disclaimer { font-size: 0.75rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 1rem; margin-bottom: 1.5rem; }
.btn-print { width: 100%; background: transparent; border: 1px solid var(--border); padding: 12px; border-radius: 10px; cursor: pointer; font-weight: 600; transition: background 0.3s; }
.btn-print:hover { background: #f9fafb; }

/* FAQ */
.faq-container { margin: 4rem 0; }
.faq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 2rem; }
.faq-item { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 0.5rem; }
.faq-item summary { font-weight: 700; cursor: pointer; padding: 1rem; outline: none; }
.faq-item p { padding: 0 1rem 1rem 1rem; color: var(--muted); font-size: 0.9rem; }

/* Tabs Content */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Law Tab */
.law-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.9rem; }
.law-table th, .law-table td { border: 1px solid var(--border); padding: 12px; text-align: left; }
[dir="rtl"] .law-table th, [dir="rtl"] .law-table td { text-align: right; }
.law-links { margin: 1.5rem 0; padding-left: 1.5rem; }
[dir="rtl"] .law-links { padding-left: 0; padding-right: 1.5rem; }
.law-links a { color: var(--primary); text-decoration: underline; }
.law-note { font-size: 0.85rem; color: var(--muted); padding: 1rem; background: #fffbeb; border-radius: 10px; border: 1px solid #fef3c7; }

/* GCC Tabs */
.sub-tab-nav { display: flex; gap: 8px; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 10px; overflow-x: auto; }
.sub-btn { background: #f1f5f9; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.sub-btn.active { background: var(--primary); color: white; }
.sub-tab-content { display: none; }
.sub-tab-content.active { display: block; }

/* Back to Top */
.back-to-top {
    position: fixed; bottom: 30px; right: 30px; width: 45px; height: 45px;
    background: var(--primary); color: white; border: none; border-radius: 50%;
    cursor: pointer; opacity: 0; transition: 0.4s; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(20px);
}
[dir="rtl"] .back-to-top { right: auto; left: 30px; }
.back-to-top.visible { opacity: 1; transform: translateY(0); }

.footer { text-align: center; padding: 4rem 0; color: var(--muted); font-size: 0.85rem; }

/* Print Logic */
@media print {
    .no-print { display: none !important; }
    body { background: white; }
    .container { max-width: 100%; margin: 0; padding: 0; }
    .calculator-grid { display: block; }
    .result-card { position: relative; top: 0; border: none; box-shadow: none; padding: 0; margin: 0 auto; width: 90%; text-align: center; }
    .badge { border: 1px solid var(--success); }
    .total-display { color: black; border-bottom: 2px solid black; display: inline-block; padding-bottom: 5px; }
    .breakdown-table th, .breakdown-table td { color: black; border-color: #eee; }
    .only-print { display: block !important; margin-bottom: 2rem; }
    .employee-meta { text-align: left; }
    [dir="rtl"] .employee-meta { text-align: right; }
}

.only-print { display: none; }

/* Responsive */
@media (max-width: 900px) {
    .calculator-grid { grid-template-columns: 1fr; }
    .sticky { position: static; }
    .faq-grid { grid-template-columns: 1fr; }
    .page-intro h1 { font-size: 1.8rem; }
}