/* ===== GT-ZAKAT - ملف الأنماط الرئيسي (النسخة النهائية المتجاوبة) ===== */

/* ===== الخط المخصص ===== */
@font-face {
    font-family: 'Ubuntu Arabic';
    src: url('../fonts/Ubuntu Arabic Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ===== RESET & المتغيرات العامة ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.2s ease, border-color 0.2s ease;
}

:root {
    /* الألوان الأساسية */
    --md-primary: #1e7e6c;
    --md-primary-light: #4b9b8a;
    --md-primary-dark: #0e5244;
    
    /* الوضع الفاتح */
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1f1f1f;
    --text-secondary: #5f5f5f;
    --border: #e0e0e0;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.08);
    --card-bg: #ffffff;
    --hover-bg: rgba(30, 126, 108, 0.05);
    --result-bg: rgba(30, 126, 108, 0.1);
    --tooltip-bg: #ffffff;
}

[data-theme="dark"] {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #e9e9e9;
    --text-secondary: #aaaaaa;
    --border: #333333;
    --card-bg: #2a2a2a;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    --hover-bg: rgba(30, 126, 108, 0.2);
    --result-bg: rgba(30, 126, 108, 0.15);
    --tooltip-bg: #2a2a2a;
}

/* ===== التخطيط الأساسي ===== */
body {
    font-family: 'Ubuntu Arabic', 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 0 20px 0;
    direction: rtl;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* ===== شريط التطبيق والشعار النصي ===== */
.app-bar {
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(4px);
}

.app-bar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 8px;
    position: relative;
}

.logo-link::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--md-primary);
    transform: scaleX(0);
    transition: transform 0.2s;
}

.logo-link:hover::after {
    transform: scaleX(1);
}

.logo-icon {
    font-size: 2.4rem;
    color: var(--md-primary);
    transition: transform 0.2s;
}

.logo-link:hover .logo-icon {
    transform: rotate(5deg) scale(1.1);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 500;
    background: linear-gradient(145deg, var(--md-primary), #0a4b44);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-right: 8px;
    border-right: 2px solid var(--md-primary);
    padding-right: 8px;
    white-space: nowrap;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background 0.2s;
}

.action-btn:hover {
    background: var(--hover-bg);
}

.lang-toggle {
    font-size: 1rem;
    padding: 0 16px;
    border-radius: 30px;
    background: var(--md-primary);
    color: white;
    border: none;
    height: 40px;
    cursor: pointer;
    font-weight: 500;
    min-width: 100px;
    transition: background 0.2s;
}

.lang-toggle:hover {
    background: var(--md-primary-dark);
}

/* ===== القسم الترحيبي ===== */
.hero {
    text-align: center;
    margin: 32px 0 20px;
}

.hero h1 {
    font-size: 2.4rem;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text);
}

.badge {
    background: var(--md-primary-light);
    color: white;
    padding: 4px 16px;
    border-radius: 30px;
    display: inline-block;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ===== البطاقات ===== */
.card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.card h1, .card h2 {
    font-size: 1.8rem;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-primary);
}

.card h2 {
    font-size: 1.5rem;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

/* ===== بطاقات الزكاة ===== */
.zakat-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.zakat-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 24px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.zakat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--md-primary);
    transform: scaleX(0);
    transition: transform 0.3s;
}

.zakat-card:hover {
    transform: translateY(-8px);
    border-color: var(--md-primary);
    box-shadow: 0 12px 24px rgba(30, 126, 108, 0.2);
}

.zakat-card:hover::before {
    transform: scaleX(1);
}

.zakat-card .material-icons-round {
    font-size: 3rem;
    color: var(--md-primary);
    margin-bottom: 16px;
    transition: transform 0.3s;
}

.zakat-card:hover .material-icons-round {
    transform: scale(1.1) rotate(5deg);
}

.zakat-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text);
}

.zakat-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ===== علامات التبويب ===== */
.madhhab-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.madhhab-tab {
    background: transparent;
    border: 1px solid var(--border);
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
    transition: all 0.2s;
    font-family: 'Ubuntu Arabic', 'Roboto', sans-serif;
}

.madhhab-tab:hover {
    background: var(--hover-bg);
    border-color: var(--md-primary);
}

.madhhab-tab.active {
    background: var(--md-primary);
    color: white;
    border-color: var(--md-primary);
}

/* ===== حقول الإدخال ===== */
.input-field, .currency-select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    margin: 8px 0 16px;
    font-family: 'Ubuntu Arabic', 'Roboto', sans-serif;
    direction: ltr;
    text-align: right;
}

.currency-select {
    direction: ltr;
}

.currency-select option {
    direction: rtl;
    text-align: right;
}

.input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-group .input-field {
    flex: 2;
}

.input-group .currency-select {
    flex: 1;
    min-width: 140px;
}

label {
    font-weight: 500;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

/* ===== الأزرار ===== */
.btn {
    background: var(--md-primary);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: background 0.2s, transform 0.1s;
    font-family: 'Ubuntu Arabic', 'Roboto', sans-serif;
}

.btn:hover {
    background: var(--md-primary-dark);
    transform: scale(0.98);
}

.toggle-manual-btn {
    background: transparent;
    border: 2px solid var(--md-primary);
    color: var(--md-primary);
    padding: 8px 16px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Ubuntu Arabic', 'Roboto', sans-serif;
}

.toggle-manual-btn:hover {
    background: var(--md-primary);
    color: white;
}

/* ===== نتائج الحساب ===== */
.result-box {
    background: var(--result-bg);
    padding: 20px;
    border-radius: 16px;
    margin-top: 20px;
    font-size: 1.2rem;
    font-weight: 500;
    border-right: 4px solid var(--md-primary);
    line-height: 1.8;
    direction: ltr;
    text-align: right;
}

.result-box small {
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--text-secondary);
}

/* ===== روابط المصادر ===== */
.source-link {
    color: var(--md-primary);
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px dashed;
    margin-right: 8px;
    transition: border-bottom 0.2s;
}

.source-link:hover {
    border-bottom-style: solid;
}

/* ===== أزرار التنقل بين الصفحات ===== */
.page-navigation {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    gap: 16px;
    flex-wrap: wrap;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--md-primary);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 40px;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
    box-shadow: var(--shadow);
}

.nav-button:hover {
    background: var(--md-primary-dark);
    transform: translateY(-2px);
}

.nav-button .material-icons-round {
    font-size: 1.4rem;
}

.nav-button.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: var(--text-secondary);
}

/* ===== معلومات النصاب ===== */
.nisab-info {
    background: var(--hover-bg);
    padding: 16px;
    border-radius: 16px;
    margin: 16px 0;
}

.nisab-info p {
    margin: 8px 0;
    direction: ltr;
    text-align: right;
}

/* ===== Tooltip ===== */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 1px dashed var(--md-primary);
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: var(--tooltip-bg);
    color: var(--text);
    text-align: center;
    border-radius: 8px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    pointer-events: none;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ===== الإدخال اليدوي ===== */
.manual-price-input {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 20px 0;
    padding: 16px;
    background: var(--hover-bg);
    border-radius: 16px;
}

.manual-price-input label {
    flex: 1;
}

.manual-price-input input {
    width: 150px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: 'Ubuntu Arabic', 'Roboto', sans-serif;
    direction: ltr;
}

/* ===== الشارات ===== */
.price-source-badge {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 20px;
    background: var(--md-primary);
    color: white;
    margin-left: 10px;
    display: inline-block;
}

/* ===== القوائم ===== */
ul {
    list-style: none;
    padding-right: 0;
}

ul li {
    margin-bottom: 12px;
    padding-right: 24px;
    position: relative;
}

ul li::before {
    content: "•";
    color: var(--md-primary);
    font-weight: bold;
    position: absolute;
    right: 0;
}

/* ===== تذييل الصفحة ===== */
.footer {
    text-align: center;
    margin-top: 48px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--md-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== تحسينات للغة الإنجليزية ===== */
[dir="ltr"] {
    direction: ltr;
}

[dir="ltr"] body {
    text-align: left;
}

[dir="ltr"] .tagline {
    margin-right: 0;
    margin-left: 8px;
    border-right: none;
    border-left: 2px solid var(--md-primary);
    padding-right: 0;
    padding-left: 8px;
}

[dir="ltr"] ul li {
    padding-right: 0;
    padding-left: 24px;
}

[dir="ltr"] ul li::before {
    right: auto;
    left: 0;
}

[dir="ltr"] .result-box {
    border-right: none;
    border-left: 4px solid var(--md-primary);
    text-align: left;
}

[dir="ltr"] .input-field, 
[dir="ltr"] .currency-select {
    text-align: left;
}

[dir="ltr"] .nisab-info p {
    text-align: left;
}

[dir="ltr"] .tooltip .tooltip-text {
    left: 0;
    transform: translateX(0);
}

/* ===== تحسينات الوضع المظلم ===== */
[data-theme="dark"] .logo-text {
    background: linear-gradient(145deg, #4b9b8a, #1e7e6c);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="dark"] .badge {
    background: var(--md-primary-dark);
}

[data-theme="dark"] .result-box {
    background: rgba(30, 126, 108, 0.2);
}

[data-theme="dark"] .zakat-card:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

/* ===== تحسينات عامة ===== */
.note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-style: italic;
}

.material-icons-round {
    vertical-align: middle;
}

/* ضمان ظهور الأرقام بالشكل الغربي */
input, select, button, .result-box, .nisab-info p, .price-source-badge, #lastUpdateNote {
    font-feature-settings: "tnum";
}

/* ===== تحسينات متقدمة للشاشات الصغيرة (Responsive) ===== */

/* للشاشات الصغيرة جداً (أقل من 400px) */
@media (max-width: 400px) {
    .app-bar .container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .logo-area {
        justify-content: space-between;
        width: 100%;
    }
    
    .logo-link {
        flex-shrink: 0;
    }
    
    .logo-text {
        font-size: 1.2rem;
    }
    
    .tagline {
        font-size: 0.8rem;
        margin-right: 4px;
        padding-right: 4px;
        white-space: normal;
        text-align: left;
        flex: 1;
    }
    
    .actions {
        justify-content: space-between;
        width: 100%;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
    }
    
    .lang-toggle {
        min-width: 80px;
        font-size: 0.9rem;
        padding: 0 8px;
    }
    
    .hero h1 {
        font-size: 1.5rem;
    }
    
    .badge {
        font-size: 0.8rem;
        padding: 4px 12px;
    }
}

/* للشاشات المتوسطة (بين 401px و 600px) */
@media (min-width: 401px) and (max-width: 600px) {
    .app-bar .container {
        flex-wrap: wrap;
    }
    
    .logo-area {
        flex: 1 1 auto;
    }
    
    .actions {
        flex: 0 0 auto;
    }
    
    .tagline {
        white-space: normal;
        font-size: 0.85rem;
    }
}

/* تحسينات إضافية لبطاقات الزكاة على الهاتف */
@media (max-width: 600px) {
    .zakat-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .zakat-card {
        padding: 16px 8px;
    }
    
    .zakat-card .material-icons-round {
        font-size: 2.2rem;
    }
    
    .zakat-card h3 {
        font-size: 1rem;
    }
    
    .zakat-card p {
        font-size: 0.8rem;
    }
    
    .card {
        padding: 16px;
    }
    
    .card h2 {
        font-size: 1.3rem;
    }
    
    .input-field, .currency-select {
        padding: 12px;
        font-size: 0.95rem;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    .madhhab-tabs {
        gap: 4px;
    }
    
    .madhhab-tab {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .result-box {
        padding: 16px;
        font-size: 1rem;
    }
    
    .page-navigation {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav-button {
        width: 100%;
        justify-content: center;
    }
}

/* تحسينات للشاشات الصغيرة جداً (أقل من 350px) */
@media (max-width: 350px) {
    .logo-area {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .tagline {
        margin-right: 0;
        border-right: none;
        padding-right: 0;
        text-align: center;
    }
    
    [dir="ltr"] .tagline {
        margin-left: 0;
        border-left: none;
        padding-left: 0;
    }
    
    .actions {
        justify-content: center;
    }
    
    .zakat-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .currency-select {
        font-size: 0.85rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group .currency-select {
        width: 100%;
    }
}

/* تحسينات للغة الإنجليزية على الهاتف */
@media (max-width: 400px) {
    [dir="ltr"] .logo-area {
        justify-content: space-between;
    }
    
    [dir="ltr"] .tagline {
        margin-left: 4px;
        padding-left: 4px;
        text-align: right;
    }
}

/* تحسينات لأزرار المعلومات على الشاشات الصغيرة */
@media (max-width: 480px) {
    .more-info-btn {
        width: 100%;
        justify-content: center;
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .tooltip .tooltip-text {
        width: 200px;
        font-size: 0.75rem;
    }
}

/* تحسينات للشاشات المتوسطة */
@media (min-width: 601px) and (max-width: 1024px) {
    .container {
        padding: 0 20px;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .zakat-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== إصلاحات إضافية للهاتف (لضمان عدم نزول العناصر) ===== */
@media (max-width: 480px) {
    /* إجبار العناصر على البقاء في سطر واحد */
    .app-bar .container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .logo-area {
        width: auto !important;
        flex: 1 1 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    
    .actions {
        width: auto !important;
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
    }
    
    /* إذا كانت الشاشة صغيرة جداً، نخفي العبارة الجانبية */
    .tagline {
        display: inline-block !important;
        font-size: 0.7rem !important;
        margin-right: 4px !important;
        padding-right: 4px !important;
        white-space: nowrap !important;
        max-width: 100px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* للشاشات الضيقة جداً، نخفي العبارة تماماً */
    @media (max-width: 380px) {
        .tagline {
            display: none !important;
        }
    }
    
    .logo-text {
        font-size: 1.1rem !important;
    }
    
    .lang-toggle {
        min-width: 70px !important;
        font-size: 0.8rem !important;
        padding: 0 6px !important;
    }
    
    .action-btn {
        width: 36px !important;
        height: 36px !important;
    }
}

/* تحسينات للشاشات الصغيرة جداً جداً */
@media (max-width: 360px) {
    .logo-text {
        font-size: 1rem !important;
    }
    
    .lang-toggle {
        min-width: 60px !important;
        font-size: 0.75rem !important;
    }
    
    .action-btn {
        width: 32px !important;
        height: 32px !important;
    }
}
