/*---------------- فونت وزیر ----------------*/
@font-face {
    font-family: 'Vazir';
    src: url('vazir-font-v16.1.0/Vazir-Medium.woff2') format('woff2'),
        url('vazir-font-v16.1.0/Vazir-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
}
* {
    scroll-behavior: smooth;
}
.askal {
    text-decoration: none;
}
@font-face {
    font-family: 'Vazirb';
    src: url('vazir-font-v16.1.0/Vazir-Bold.woff2') format('woff2'),
        url('vazir-font-v16.1.0/Vazir-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
}

body {
    font-family: 'Vazir', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    direction: rtl;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    width: 40px;
    height: 40px;
    margin-left: 10px;
    border-radius: 5px;
}

header h1 {
    font-family: 'Vazirb', sans-serif;
    margin: 0;
    font-size: 24px;
}

main {
    flex: 1;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    /* Allow wrapping on smaller screens */
}

.section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 25px;
    margin-bottom: 20px;
    width: 100%;
    /* Full width by default */
    max-width: 900px;
    /* Max width for content */
    display: none;
    /* Hidden by default */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.section.active {
    display: block;
    opacity: 1;
}

.section h2 {
    font-family: 'Vazirb', sans-serif;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.input-group input[type="number"],
.input-group input[type="text"],
.input-group textarea {
    width: calc(100% - 20px);
    padding: 12px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: 'Vazir', sans-serif;
    font-size: 15px;
    box-sizing: border-box;
    /* Include padding and border in the element's total width and height */
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    /* Allow buttons to wrap */
    gap: 10px;
    /* Space between buttons */
    margin-top: 15px;
    justify-content: center;
}

button {
    font-family: 'Vazirb', sans-serif;
    padding: 12px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.operator {
    background-color: #e67e22;
}

.operator:hover {
    background-color: #d35400;
}

.equals {
    background-color: #27ae60;
}

.equals:hover {
    background-color: #229954;
}

/* ------------- Bottom Navigation ------------- */
.bottom-nav {
    background-color: #34495e;
    color: white;
    padding: 10px 0;
    position: sticky;
    bottom: 0;
    width: 100%;
    overflow-x: auto;
    /* Enable horizontal scrolling */
    white-space: nowrap;
    /* Prevent items from breaking to next line */
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.nav-list {
    display: inline-flex;
    /* Use inline-flex for horizontal layout */
    padding: 0 15px;
    /* Add some horizontal padding */
}

.nav-item {
    background-color: transparent;
    color: white;
    padding: 10px 20px;
    margin: 0 5px;
    /* Spacing between buttons */
    border: none;
    cursor: pointer;
    font-size: 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
    border-radius: 5px;
    flex-shrink: 0;
    /* Prevent buttons from shrinking */
}

.nav-item:hover {
    background-color: #4a627a;
}

/* ریسپانسیو برای گوشی */
@media (max-width: 480px) {
    .calculator-container button {
        height: 60px;
        /* دکمه‌های بزرگتر برای راحتی انگشت */
        font-size: 1.2rem;
    }

}

.formola {
    color: gray;
    font-size: 10px;
    direction: ltr;
    
}

/* Calculator Wrapper */
.calculator {
    direction: ltr;
    background-color: #333;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
    overflow: hidden;
    width: 360px;         /* کمی عریض‌تر */
    max-width: 95vw;      /* محدود در گوشی */
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* Top Display Section */
.top {
    padding: 18px;
    background-color: #222;
    text-align: right;
    border-bottom: 1px solid #444;
}

.result {
    font-size: 1.1em;
    color: #999;
    min-height: 24px;
    letter-spacing: 0.5px;
}

.screen .screentext {
    font-size: 2em;
    color: #fff;
    font-weight: bold;
    display: block;
    min-height: 45px;
    word-wrap: break-word;
    overflow: hidden;
}

/* Keyboard Layout */
.keyboard {
    padding: 10px;
}

.crow {
    display: flex;
    margin-bottom: 6px;
    flex-wrap: nowrap;
}

.cb {
    flex: 1;
    margin: 3px;
    padding: 13px 8px;
    font-size: 1.05em;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    background-color: #555;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.cb:active {
    transform: scale(0.94);
}

/* نوع دکمه‌ها */
.cbnum { background-color: #444; }
.cbop, .cbpar { background-color: #666; }
.cbop.operands, .cbenter, .cbac, .cbce { background-color: #f59700; color: #fff; }
.cbfun, .cbinv, .cbrnd, .cbans { background-color: #666; }

/* Hover states */
.cb:hover { background-color: #777; }
.cbop.operands:hover,
.cbac:hover,
.cbce:hover,
.cbenter:hover { background-color: #ffb74d; }

.cb.cbfun sup.inv {
    font-size: 0.65em;
    color: #ccc;
    margin-left: 3px;
}

/* مساوی پهن‌تر */
.cbenter {
    flex: 2;
}

/* Animation برای فید شدن در نمایشگر */
.screentext.animated {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===============================
   📱 ریسپانسیو برای گوشی‌ها
   =============================== */
@media (max-width: 600px) {
    .calculator {
        width: 95vw;
        border-radius: 10px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    }

    .top {
        padding: 14px;
    }

    .screen .screentext {
        font-size: 1.7em;
    }

    .crow {
        margin-bottom: 5px;
    }

    .cb {
        margin: 2px;
        padding: 12px 6px;
        font-size: 0.95em;
        border-radius: 5px;
    }

    .cbenter {
        flex: 1.6;
    }
}

/* حالت خیلی کوچک‌تر (عرض زیر 400px) */
@media (max-width: 400px) {
    .calculator {
        width: 85vw;
    }

    .screen .screentext {
        font-size: 1.4em;
        min-height: 35px;
    }

    .cb {
        font-size: 0.9em;
        padding: 10px 4px;
        margin: 2px;
    }
}


/* ------------- Analysis, Functions, Geometry Sections ------------- */
#analysis-output,
#numbers-output,
#functions-output,
#geometry-output {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    min-height: 50px;
    white-space: pre-wrap;
    /* Preserve whitespace and line breaks */
    word-wrap: break-word;
    /* Break long words */
}

.functions-list p {
    margin-bottom: 10px;
    font-size: 15px;
    line-height: 1.6;
}

.functions-list code {
    background-color: #eef;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* ------------- Geometry Section ------------- */
.geometry-shapes {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.shape-item {
    background-color: #f1f8ff;
    border: 1px solid #b3e5fc;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 120px;
    box-sizing: border-box;
}

.shape-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.shape-item img {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
    object-fit: contain;
    /* Ensure image is scaled properly */
}

.shape-item span {
    font-weight: 500;
    color: #333;
}

#shape-inputs {
    margin-top: 25px;
    padding: 20px;
    background-color: #f0f8ff;
    border: 1px dashed #90caf9;
    border-radius: 8px;
    text-align: center;
}

#shape-inputs label,
#shape-inputs input {
    display: inline-block;
    /* Allow label and input on same line */
    margin: 5px 8px;
}

/* ------------- Charts Section ------------- */
#chart-output {
    position: relative;
    height: 400px;
    /* Set a fixed height for the canvas container */
    width: 100%;
    margin-top: 20px;
    background-color: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

/* ------------- About Section ------------- */
.about-box {
    text-align: center;
    padding: 20px;
    background-color: #e8f5e9;
    border-radius: 8px;
    border: 1px solid #a5d6a7;
}

.about-box p {
    font-size: 16px;
    margin-bottom: 15px;
}

.social-icons {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.social-icons img {
    width: 35px;
    height: 35px;
    transition: transform 0.3s ease;
}

.social-icons img:hover {
    transform: scale(1.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        padding: 10px 15px;
    }

    header h1 {
        font-size: 20px;
    }

    .logo {
        width: 35px;
        height: 35px;
    }

    .section {
        padding: 20px;
    }

    .bottom-nav {
        padding: 5px 0;
    }

    .nav-item {
        padding: 8px 15px;
        font-size: 13px;
    }

    .calculator-container {
        max-width: 300px;
    }

    #calculator-display {
        font-size: 24px;
    }

    .calculator-container button {
        font-size: 16px;
        padding: 15px;
    }

    .geometry-shapes {
        justify-content: space-around;
    }

    .shape-item {
        width: 100px;
        padding: 10px;
    }

    .shape-item img {
        width: 50px;
        height: 50px;
    }
}

/* فقط بخش CSS مربوط به توابع */
.functions-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    /* فاصله بین دکمه‌ها */
    margin-bottom: 20px;
    justify-content: center;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #f9f9f9;
}

/* ریسپانسیو کردن دکمه‌های توابع */
.functions-buttons-container {
    display: grid;
    /* این خط باعث می‌شود در موبایل ۲ ستون و در دسکتاپ ۶ ستون داشته باشیم */
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

/* برای تبلت‌ها و صفحات بزرگتر، تعداد ستون‌ها را بیشتر می‌کنیم */
@media (min-width: 600px) {
    .functions-buttons-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 900px) {
    .functions-buttons-container {
        grid-template-columns: repeat(6, 1fr);
    }
}

.func-button {
    font-family: 'Vazir', sans-serif;
    padding: 12px 5px;
    /* کمی پدینگ عمودی بیشتر برای راحتی کلیک در موبایل */
    background-color: #3498db;
    /* رنگ آبی جذاب‌تر */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    width: 100%;
    /* دکمه کل عرض ستون خود را می‌گیرد */
}

.func-button:hover {
    background-color: #2980b9;
}
.func-button {
    font-family: 'Vazir', sans-serif;
    padding: 6px 10px;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.25s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    margin: 6px;
    min-width: 60px;
    text-align: center;
}

/* متن کوچیک زیر نماد */
.func-button span {
    display: block;
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
}

/* هاور */
.func-button:hover {
    background: linear-gradient(135deg, #2a5298, #1e3c72);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

/* کلیک */
.func-button:active {
    transform: scale(0.95);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}


/* —— ریسپانسیو برای موبایل —— */
@media (max-width: 600px) {
    .func-buttons-wrapper {
        justify-content: center;
        padding: 5px;
    }
.functions-buttons-container {
    
  display: grid;
    grid-template-columns: repeat(4, auto); /* دقیقاً ۴ ستون */
    justify-content: center;  /* وسط‌چین کردن کل شبکه */
    gap: 6px; /* فاصله بین دکمه‌ها */
}

    .func-button {

        padding: 4px 6px;
        font-size: 11px;
        border-radius: 8px;
        margin: 4px;
        min-width:40px;
        width: 30px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
        
    }

    .func-button span {
        font-size: 9px;
    }
}

/* برای گوشی‌های خیلی کوچک مثل 320px */
@media (max-width: 380px) {
    .func-button {
        padding: 3px 5px;
        font-size: 10px;
        margin: 3px;
        min-width: 55px;
    }

    .func-button span {
        font-size: 8.5px;
    }
}

/* استایل‌های مربوط به ورودی و دکمه محاسبه در بخش توابع */
#functions .input-group {
    margin-top: 15px;
    /* فاصله بیشتر از دکمه‌ها */
    text-align: center;
    /* مرکز کردن ورودی و دکمه */
}

#functions .input-group input[type="text"] {
    width: 60%;
    /* عرض کمتر برای ورودی */
    display: inline-block;
    /* نمایش در کنار دکمه */
    margin-left: 10px;
    vertical-align: middle;
    /* هم‌ترازی عمودی */
}

#functions .input-group button {
    display: inline-block;
    vertical-align: middle;
    padding: 12px 25px;
    /* کمی بزرگتر کردن دکمه محاسبه */
}

.geometry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    padding: 20px;
}

.geo-card {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.geo-card:hover {
    transform: translateY(-5px);
}

.geo-card svg {
    margin-bottom: 10px;
}

.geo-card input {
    width: 90%;
    margin: 5px 0;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.geo-card button {
    width: 100%;
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 5px;
}

/* =========================
   GEOMETRY PRO GRID
========================= */

.geo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 15px;
}

.geo-item {
    background: linear-gradient(135deg, #ffffff, #f1f5f9);
    border-radius: 18px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.geo-item span {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #334155;
}

.geo-item svg {
    width: 55px;
    height: 55px;
    transition: 0.3s;
}

.geo-item:hover {
    transform: translateY(-6px) scale(1.05);
    background: linear-gradient(135deg, #2563eb, #60a5fa);
}

.geo-item:hover span {
    color: white;
}

.geo-item:hover svg {
    transform: scale(1.15);
    filter: brightness(200%);
}

#geo-form {
    margin-top: 20px;
    padding: 15px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
}

#geoResult {
    margin-top: 15px;
    font-weight: bold;
    color: #2563eb;
}

.trig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.trig-card {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    padding: 16px;
    border-radius: 18px;
    text-align: center;
    color: white;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.trig-card:hover {
    transform: translateY(-6px) scale(1.05);
}

.trig-icon {
    font-size: 26px;
    font-weight: bold;
    margin-bottom: 6px;
}

.trig-card span {
    font-size: 12px;
    opacity: 0.9;
}

/* =========================
   INPUTS
========================= */
input,
textarea,
select {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    border-radius: 14px;
    border: 1px solid #dbeafe;
    background: #f8fafc;
    font-size: 15px;
    transition: 0.2s;
    margin-bottom: 10px;
    font-family: 'Vazir', sans-serif;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #2563eb;
    background: #ffffff;
}

textarea {
    resize: none;
    min-height: 80px;
}

#charts-section {
    padding: 40px 20px;
    background: linear-gradient(180deg, #e0f7fa, #ffffff);
    /* پس‌زمینه روشن و آبی ملایم */
    border-radius: 25px;
    margin-top: 40px;
}

#charts-section h2 {
    text-align: center;
    color: #00796b;
    /* رنگ سبزآبی تیره */
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.1);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    /* تنظیم اندازه نمودارها */
    gap: 30px;
}

.chart-container {
    background-color: #ffffff;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-container:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.chart-container h3 {
    color: #00796b;
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

/* استایل canvas برای اطمینان از نمایش صحیح */
.chart-container canvas {
    max-width: 100%;
    height: auto !important;
    /* اجازه می دهد ارتفاع خودکار تنظیم شود */
    display: block;
    /* برای حذف فضای اضافی زیر canvas */
}

/* CSS بالا را اینجا قرار دهید */
.loader-container {
    width: 300px;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    position: fixed;
    /* برای اینکه در همه حال دیده شود */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    /* اطمینان از اینکه بالای همه چیز قرار گیرد */
}

.loader-bar {
    height: 100%;
    width: 30%;
    background-color: #3498db;
    /* رنگ لودر */
    border-radius: 3px;
    animation: loading 1.5s infinite ease-in-out;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

/* استایل برای محتوای صفحه */
.content {
    padding: 20px;
}

/* استایل دهی به div که بنر در آن نمایش داده می‌شود */
#banner-container {
    width: 300px;
    /* مثال: عرض بنر */
    height: 250px;
    /* مثال: ارتفاع بنر */
    border: 1px solid #ccc;
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: #f0f0f0;
    /* پس‌زمینه تا زمان بارگذاری بنر */
    font-family: sans-serif;
    color: #555;
}


/* استایل‌های بخش حسابان */
.section.calculus {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section.calculus h2 {
    color: #343a40;
    margin-bottom: 15px;
    text-align: center;
}

.calculus-controls {
   
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.calculus-controls label {
    color: #495057;
    font-weight: bold;
}

.calculus-controls input[type="text"],
.calculus-controls select {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    flex-grow: 1;
    min-width: 150px;
}

.calculus-controls button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.calculus-controls button:hover {
    background-color: #0056b3;
}

.result-display {
    margin-top: 20px;
    padding: 15px;
    background-color: #e9ecef;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
    font-size: 1.1rem;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057;
}

.calculus-note {
    text-align: center;
    margin-top: 25px;
    font-size: 0.9rem;
    color: #6c757d;
}

/* استایل‌های اضافی برای مخفی کردن/نمایش فیلد نقطه */
.calculus-controls input[type="text"]#calculus-point[style*="display: none"],
.calculus-controls label#calculus-point-label[style*="display: none"] {
    display: none !important;
}

  #ai-output { margin-top: 15px; padding: 15px; background-color: #f8f9fa; border-radius: 5px; border: 1px solid #ddd; min-height: 50px; white-space: pre-wrap; } /* برای حفظ فرمت متن خروجی */