/* --- Reset و تنظیمات پایه --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* حذف هایلایت پیش‌فرض هنگام لمس */
}

html {
    font-size: 16px; /* اندازه پایه فونت */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; /* فونت استاندارد و مدرن */
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460); /* گرادیانت پس‌زمینه تیره */
    color: #e0e0e0; /* رنگ متن روشن */
    direction: rtl; /* راست‌چین کردن */
    line-height: 1.6;
    height: 100vh; /* ارتفاع کامل صفحه */
    overflow: hidden; /* جلوگیری از اسکرول کل صفحه */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; /* برای پاپ‌آپ */
}

#app {
    width: 100%;
    max-width: 480px; /* حداکثر عرض برای شبیه‌سازی موبایل */
    height: 100%;
    background-color: rgba(15, 15, 30, 0.8); /* پس‌زمینه نیمه‌شفاف برای اپ */
    border-radius: 10px; /* گوشه‌های گرد (اختیاری) */
    overflow: hidden; /* محتوای اضافی مخفی شود */
    display: flex;
    flex-direction: column; /* چیدمان ستونی */
    position: relative; /* برای صفحات */
}

/* --- استایل صفحات --- */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* همه صفحات در ابتدا مخفی */
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460); /* گرادیانت برای هر صفحه */
}

.page.active {
    display: flex; /* نمایش صفحه فعال */
    opacity: 1;
    z-index: 1; /* صفحه فعال بالاتر باشد */
}

.header, .header-simple {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* جلوگیری از کوچک شدن هدر */
    z-index: 5; /* بالاتر از محتوا */
}

.header-simple {
    justify-content: center; /* عنوان وسط باشد */
    position: relative; /* برای دکمه بازگشت */
}

.header-simple h2 {
     flex-grow: 1;
     text-align: center;
     margin: 0 50px; /* فضای خالی برای دکمه بازگشت */
}

.content {
    flex-grow: 1; /* بخش محتوا بزرگ شود */
    overflow-y: auto; /* اسکرول در صورت نیاز */
    padding: 1rem;
    padding-bottom: 70px; /* فضای خالی برای نوار ناوبری */
}

.centered-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: calc(100% - 50px); /* ارتفاع منهای هدر (تقریبی) */
}

/* --- نوار ناوبری پایین --- */
.navigation-bar {
    display: flex;
    justify-content: space-around;
    background-color: rgba(10, 10, 20, 0.9);
    padding: 0.5rem 0;
    border-top: 1px solid #333;
    position: absolute; /* ثابت در پایین */
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

.nav-item {
    background: none;
    border: none;
    color: #aaa;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}

.nav-item.active {
    color: #e94560; /* رنگ آیتم فعال */
    font-weight: bold;
}

.nav-item:hover {
    color: #fff;
}

/* --- استایل دکمه‌ها --- */
.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 25px; /* گوشه‌های گردتر */
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    text-align: center;
}

.btn:active {
    transform: scale(0.97); /* افکت کلیک */
}

.gradient-btn {
    background: linear-gradient(45deg, #e94560, #ff7675); /* گرادیانت برای دکمه‌های اصلی */
    color: white;
    box-shadow: 0 4px 10px rgba(233, 69, 96, 0.3);
}

.gradient-btn:hover {
     box-shadow: 0 6px 15px rgba(233, 69, 96, 0.5);
}

.cancel-btn {
    background-color: #555;
    color: #ddd;
}

.cancel-btn:hover {
    background-color: #666;
}

.link-btn {
    background: none;
    color: #a5a5ff;
    text-decoration: underline;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.close-btn {
    background-color: #444;
    color: #eee;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
}

.back-btn {
    background: none;
    color: #a5a5ff;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem;
    font-size: 1.2rem; /* بزرگتر */
}

/* دکمه‌های صفحه خانه */
.home-buttons {
    display: flex;
    justify-content: space-around;
    padding: 1rem;
    position: absolute;
    bottom: 70px; /* بالای نوار ناوبری اصلی */
    width: 100%;
    left: 0;
    z-index: 5;
}

.add-book-btn {
    background: linear-gradient(45deg, #56ab2f, #a8e063); /* گرادیانت سبز */
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 2.5rem; /* اندازه بزرگ برای + */
    line-height: 55px; /* تنظیم عمودی + */
    padding: 0;
    box-shadow: 0 4px 10px rgba(86, 171, 47, 0.4);
}
.add-book-btn:hover {
     box-shadow: 0 6px 15px rgba(86, 171, 47, 0.6);
}

.nav-btn { /* دکمه های List و Books در صفحه Home */
    background-color: rgba(255, 255, 255, 0.1);
    color: #eee;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- استایل کاراکتر --- */
.character-image {
    max-width: 70%; /* اندازه بزرگ کاراکتر */
    height: auto;
    margin-top: -2rem; /* کمی بالاتر برود */
    cursor: pointer;
    transition: transform 0.3s ease;
}
.character-image:hover {
    transform: scale(1.05);
}

.profile-character-image {
    max-width: 50%;
    height: auto;
    margin-bottom: 1rem;
}

/* --- پاپ آپ --- */
.popup-overlay {
    position: fixed; /* ثابت روی صفحه */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* پس‌زمینه تیره نیمه‌شفاف */
    backdrop-filter: blur(8px); /* افکت شیشه‌ای مات */
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0; /* انیمیشن */
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#discount-popup:target, /* برای نمایش با :target (اگر از لینک استفاده شود) */
#discount-popup.visible { /* برای نمایش با JS */
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background-color: rgba(30, 30, 50, 0.85); /* پس‌زمینه کمی شفاف برای محتوا */
    padding: 2rem;
    border-radius: 10px;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.popup-content h3 {
    margin-bottom: 1rem;
    color: #ffcc66; /* رنگ عنوان */
}

#discount-list {
    list-style: none;
    padding: 0;
    margin-bottom: 1rem;
    text-align: right; /* راست‌چین کردن لیست */
}

#discount-list li {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

#discount-list li a {
    color: #baddf9; /* رنگ لینک‌ها */
    text-decoration: none;
    display: block;
}

#discount-list li a:hover {
    color: #fff;
    text-decoration: underline;
}

/* --- صفحه لاگین --- */
.login-container {
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.login-container h2 {
    margin-bottom: 2rem;
    color: #e94560;
}

.login-container p {
    margin-bottom: 1rem;
    color: #ccc;
}

.login-container input[type="tel"],
.login-container input[type="text"] {
    width: 100%;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid #444;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center; /* شماره و کد وسط‌چین */
}

.login-container input[type="tel"]::placeholder,
.login-container input[type="text"]::placeholder {
    color: #888;
}

.login-container .message {
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2em; /* فضایی برای پیام */
}

.login-container .message.error {
    color: #ff7675; /* رنگ خطا */
}
.login-container .message.success {
    color: #a8e063; /* رنگ موفقیت */
}

#otp-step {
    margin-top: 2rem;
}

/* --- لیست و کارت کتاب‌ها --- */
.book-list {
    list-style: none;
    padding: 0;
}

.list-item, .card-item {
    background-color: rgba(255, 255, 255, 0.05);
    margin-bottom: 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden; /* برای swipe */
    position: relative; /* برای swipe */
}

/* استایل نمای لیست */
.list-view .list-item .swipe-content {
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    cursor: pointer; /* برای هدایت به صفحه info */
}

.list-view .book-type-icon {
    font-size: 1.5rem;
    margin-left: 0.8rem;
}
.list-view .book-title {
    font-weight: bold;
    margin-left: 0.5rem;
}
.list-view .book-author {
    color: #ccc;
    margin-left: 0.5rem;
}
.list-view .book-discount {
    color: #fbc531; /* رنگ تخفیف */
    font-size: 0.9rem;
    margin-right: auto; /* هل دادن به سمت راست */
    background-color: rgba(251, 197, 49, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

/* استایل نمای کارت */
.card-view .book-card {
    padding: 1rem;
}
.card-view .book-card p {
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}
.card-view .book-card p strong {
    color: #aaa;
    min-width: 70px; /* برای هم‌ترازی */
    display: inline-block;
}
.card-view .original-price {
    text-decoration: line-through;
    color: #aaa;
    font-size: 0.9em;
}
.card-view .discount-percent {
    color: #fbc531;
    font-weight: bold;
}
.card-view .final-price {
    color: #a8e063; /* رنگ سبز برای قیمت نهایی */
    font-weight: bold;
    font-size: 1.1em;
}
.card-view .info-btn {
    margin-top: 0.8rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: linear-gradient(45deg, #4facfe, #00f2fe); /* گرادیانت آبی */
    color: white;
}


/* --- قابلیت Swipe to Delete (ظاهر) --- */
.swipe-container {
    position: relative;
    overflow: hidden;
}

.swipe-content {
    position: relative;
    z-index: 2;
    background: inherit; /* رنگ پس‌زمینه آیتم */
    transition: transform 0.3s ease; /* انیمیشن حرکت */
}

.swipe-action {
    position: absolute;
    top: 0;
    left: 0; /* دکمه در سمت چپ */
    height: 100%;
    width: 80px; /* عرض دکمه حذف */
    background-color: #e94560; /* رنگ دکمه حذف */
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    z-index: 1;
    cursor: pointer;
    transform: translateX(-100%); /* در ابتدا مخفی در سمت چپ */
    transition: transform 0.3s ease; /* انیمیشن نمایش */
}

/* وقتی که swipe فعال می‌شود (با JS کلاس اضافه می‌شود) */
.swipe-container.swiped .swipe-content {
    transform: translateX(80px); /* محتوا به راست حرکت می‌کند */
}
.swipe-container.swiped .swipe-action {
    transform: translateX(0); /* دکمه نمایان می‌شود */
}

/* --- صفحه اطلاعات (Info) --- */
#info-content {
    text-align: center;
}
.book-cover-large {
    max-width: 60%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
#info-details {
    text-align: right; /* جزئیات راست‌چین */
    background-color: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
}
#info-details p {
    margin-bottom: 0.6rem;
    font-size: 1rem;
}
#info-details p strong {
    color: #bbb;
    min-width: 80px;
    display: inline-block;
}
/* استایل مشابه قیمت‌ها در صفحه Books */
#info-original-price { text-decoration: line-through; color: #aaa; font-size: 0.9em; }
#info-discount-percent { color: #fbc531; font-weight: bold; }
#info-final-price { color: #a8e063; font-weight: bold; font-size: 1.1em; }
#info-narrator:empty::before, #info-translator:empty::before {
    content: "ندارد"; /* نمایش 'ندارد' اگر خالی باشد */
    color: #888;
    font-style: italic;
}


/* --- صفحه افزودن کتاب --- */
.add-book-form {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}
.add-book-form p {
    margin-bottom: 1rem;
}
#book-link-input {
     width: 100%;
     padding: 0.8rem 1rem;
     margin-bottom: 1rem;
     border: 1px solid #444;
     background-color: rgba(255, 255, 255, 0.1);
     color: #fff;
     border-radius: 8px;
     font-size: 1rem;
     direction: ltr; /* لینک چپ‌چین باشد */
     text-align: left;
}
.button-group {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}
.button-group .btn {
    flex-basis: 48%; /* تقسیم فضا بین دو دکمه */
}
#add-book-message {
     margin-top: 1rem;
     font-size: 0.9rem;
     min-height: 1.2em;
}
#add-book-message.error { color: #ff7675; }
#add-book-message.success { color: #a8e063; }
#add-book-message.loading::after {
    content: ' ...'; /* انیمیشن لودینگ ساده */
    display: inline-block;
    animation: loadingDots 1s infinite;
}

@keyframes loadingDots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}


/* --- صفحه پروفایل --- */
.profile-link {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.profile-image-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 0.5rem;
    border: 1px solid #555;
}
.profile-name-small {
    font-size: 0.9rem;
    color: #ccc;
}
.profile-details {
    text-align: right;
    background-color: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    margin-top: 1rem;
}
.profile-details p {
    margin-bottom: 0.8rem;
}
.profile-details p strong {
    color: #bbb;
    min-width: 100px;
    display: inline-block;
}
#logout-btn {
    margin-top: 1.5rem;
    width: 100%; /* دکمه خروج تمام عرض */
    background-color: #b33939; /* رنگ قرمز برای خروج */
}

/* --- رسپانسیو و بهبودهای جزئی --- */
@media (max-height: 600px) {
    .character-image {
        max-width: 50%; /* کوچکتر کردن کاراکتر در صفحات کوتاه */
    }
    .centered-content {
        justify-content: flex-start; /* شروع از بالا */
        padding-top: 2rem;
    }
    .login-container {
         padding: 1rem;
    }
}

/* حذف اسکرول بار پیش‌فرض */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #777;
}