:root {
    --primary-color: #1e5652;
    --primary-light: #2b7a74;
    --bg-color: #f7f5ed;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --gold-accent: #d4af37;
    --border-radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: #e0e6e5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* محاكاة إطار الهاتف */
.app-container {
    width: 100%;
    max-width: 412px;
    height: 100vh;
    max-height: 870px;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-radius: 24px;
    overflow: hidden;
    position: relative;
}

/* الهيدر العلوي */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #ffffff;
    padding: 20px;
    text-align: center;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.header-title h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.moon-icon {
    font-size: 1.2rem;
}

/* قائمة البطاقات */
.cards-list {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

/* البطاقة الواحدة */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

/* زر الذكر */
.dhikr-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 14px 10px;
    font-family: 'Amiri', serif;
    font-size: 1.15rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    margin-left: 12px;
    box-shadow: 0 3px 6px rgba(30, 86, 82, 0.2);
}

.dhikr-btn:active {
    transform: scale(0.97);
    box-shadow: 0 1px 3px rgba(30, 86, 82, 0.4);
}

/* مربع العداد */
.counter-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    background-color: #f0f4f3;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #e2ece9;
}

.count-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.count-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* شريط التنقل السفي */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    background-color: var(--card-bg);
    padding: 12px 0;
    border-top: 1px solid #eaeaea;
}

.nav-item {
    background: none;
    border: none;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary-color);
    font-weight: 700;
}

/* مجموع تسبيحات الجميع في الهيدر */
.grand-total-badge {
    margin-top: 8px;
    font-size: 0.85rem;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}
.grand-total-badge strong {
    color: var(--gold-accent);
}

/* قسم حفظ الاسم */
.user-section {
    background-color: #fcfbfa;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.username-form {
    display: flex;
    gap: 8px;
}

.username-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d2dcd9;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.username-form input:focus {
    border-color: var(--primary-color);
}

.username-form .save-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.logout-link {
    color: #e74c3c;
    text-decoration: none;
    font-weight: 500;
}

/* لوحة المتصدرين */
.leaderboard-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.section-title {
    font-size: 1.15rem;
    color: var(--primary-color);
    margin-bottom: 14px;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.leaderboard-item.first-place {
    border: 1px solid var(--gold-accent);
    background: linear-gradient(to left, #fffdf5, var(--card-bg));
}

.leaderboard-item .rank {
    font-weight: bold;
    color: var(--text-muted);
    width: 30px;
}

.leaderboard-item.first-place .rank {
    color: var(--gold-accent);
}

.leaderboard-item .username {
    flex: 1;
    font-weight: 500;
    color: var(--text-dark);
}

.leaderboard-item .score {
    font-weight: bold;
    color: var(--primary-color);
}

.empty-list {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 20px;
}

/* تبويبات تسجيل الدخول */
.auth-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.auth-tab-btn {
    background: none;
    border: none;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.auth-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 700;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form input {
    padding: 10px 14px;
    border: 1px solid #d2dcd9;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: var(--primary-color);
}

.auth-error-msg {
    background-color: #fde8e7;
    color: #c0392b;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    margin-bottom: 10px;
    border-right: 4px solid #e74c3c;
}

.user-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.add-dhikr-trigger-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.add-dhikr-trigger-btn:hover {
    background-color: var(--primary-light);
}

/* زر التعديل للتسبيحات الخاصة */
.edit-dhikr-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    margin-right: 8px;
    transition: transform 0.2s;
}

.edit-dhikr-btn:hover {
    transform: scale(1.2);
}

/* تبويبات المتصدرين */
.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    background-color: #f0f4f3;
    padding: 4px;
    border-radius: 10px;
}

.lead-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.lead-tab-btn.active {
    background-color: white;
    color: var(--primary-color);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.leaderboard-period-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* نوافذ المودال المنبثقة */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: white;
    width: 90%;
    max-width: 320px;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--primary-color);
    font-size: 1.15rem;
    text-align: center;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input {
    padding: 10px 12px;
    border: 1px solid #d2dcd9;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-btn.confirm-btn {
    background-color: var(--primary-color);
    color: white;
}

.modal-btn.confirm-btn:hover {
    background-color: var(--primary-light);
}

.modal-btn.cancel-btn {
    background-color: #f0f0f0;
    color: var(--text-muted);
}

.modal-btn.cancel-btn:hover {
    background-color: #e0e0e0;
}

/* صفحة حول التطبيق */
.about-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.about-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.about-card h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.about-text {
    font-size: 0.85rem;
    color: var(--text-dark);
    line-height: 1.6;
}

.about-text.main-message {
    font-size: 0.95rem;
    text-align: center;
    font-family: 'Amiri', serif;
    font-weight: bold;
    color: var(--primary-color);
    line-height: 1.8;
}

.privacy-card {
    border-right: 4px solid var(--primary-color);
}

.contact-card {
    border-right: 4px solid var(--gold-accent);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
}

.contact-item {
    font-size: 0.85rem;
    color: var(--text-dark);
    text-decoration: none;
}

a.contact-item:hover {
    color: var(--primary-color);
    text-decoration: underline;
}