/* --- 1. Color Variables --- */
:root {
    --primary-color: #4A90E2;
    --secondary-color: #50E3C2;
    --background-color: #f4f7f6;
    --container-bg: #ffffff;
    --text-color: #333;
    --text-color-light: #666;
    --border-color: #ddd;
    --header-bg: #ffffff;
    --success-bg: #28a745;
    --error-bg: #dc3545;
    --info-bg: #e7f3fe;
    --info-border: #bce8f1;
    --info-text: #31708f;
    --warning-bg: #fcf8e3;
    --warning-border: #faebcc;
    --warning-text: #8a6d3b;
    --disabled-bg: #ccc;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

html.dark-mode {
    --primary-color: #58a6ff;
    --secondary-color: #50E3C2;
    --background-color: #0d1117;
    --container-bg: #161b22;
    --text-color: #c9d1d9;
    --text-color-light: #8b949e;
    --border-color: #30363d;
    --header-bg: #161b22;
    --success-bg: #3fb950;
    --error-bg: #f85149;
    --info-bg: #1f6feb26;
    --info-border: #1f6feb;
    --info-text: #58a6ff;
    --warning-bg: #f0b90026;
    --warning-border: #d4a700;
    --warning-text: #d4a700;
    --disabled-bg: #555;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* --- 2. General & Font Styles --- */
body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Vazirmatn', sans-serif;
    margin: 0;
    line-height: 1.6;
    font-size: 16px;
    transition: background-color 0.3s, color 0.3s;
}

button, input, select, textarea {
    font-family: inherit;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- 3. Header & Navigation --- */
.main-header {
    background: var(--header-bg);
    box-shadow: 0 2px 4px var(--shadow-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}
.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; 
}
/* New styles for header layout */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* On desktop, this shouldn't take full width if nav is next to it, 
       but with the new layout, we adapt */
}
.header-controls {
    display: flex;
    align-items: center;
}
.logo {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    margin-left: 20px;
}
.main-nav-links {
    display: flex;
    align-items: center;
}
.main-nav-links .nav-link {
    color: var(--text-color-light);
    text-decoration: none;
    margin: 0 15px;
    font-size: 1em;
    transition: color 0.3s;
}
.main-nav-links .nav-link:hover {
    color: var(--primary-color);
}
.main-nav-links .btn { padding: 8px 16px; border-radius: 5px; color: #fff; font-weight: 700; }
.main-nav-links .btn.btn-primary { background-color: var(--primary-color); }

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    margin-left: 10px;
    transition: background-color 0.3s, border-color 0.3s;
}
.theme-toggle:hover {
    background-color: var(--background-color);
}

.profile-menu { position: relative; display: inline-block; cursor: pointer; }
.profile-name { font-weight: 700; color: var(--text-color); }
.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--container-bg);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px var(--shadow-color);
    z-index: 1;
    border-radius: 5px;
    overflow: hidden;
    left: 0;
    border: 1px solid var(--border-color);
}
.dropdown-content a { color: var(--text-color); padding: 12px 16px; text-decoration: none; display: block; margin: 0 !important; }
.dropdown-content a:hover { background-color: var(--background-color); }
.profile-menu:hover .dropdown-content { display: block; }

/* --- 4. Main Content & Forms --- */
.main-content { padding: 40px 0; }
.auth-form-container { max-width: 450px; margin: 40px auto; padding: 30px; background: var(--container-bg); border-radius: 8px; box-shadow: 0 4px 10px var(--shadow-color); border: 1px solid var(--border-color); }
.auth-form-container h1 { text-align: center; margin-bottom: 25px; color: var(--primary-color); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 5px; box-sizing: border-box; transition: border-color 0.3s; background-color: var(--background-color); color: var(--text-color); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary-color); }
.btn-submit { width: 100%; padding: 12px; background-color: var(--primary-color); color: white; border: none; border-radius: 5px; font-size: 1.1em; font-weight: 700; cursor: pointer; transition: background-color 0.3s; }
.btn-submit:hover { background-color: #3a7ac8; }
html.dark-mode .btn-submit:hover { background-color: #7ab5ff; }
.form-link { text-align: center; margin-top: 20px; }
.form-link a { color: var(--primary-color); text-decoration: none; font-weight: 700; }

/* --- 5. Reusable Components --- */
.flash-message { padding: 15px; margin-bottom: 20px; border-radius: 5px; color: #fff; text-align: center; }
.flash-message.success { background-color: var(--success-bg); }
.flash-message.error { background-color: var(--error-bg); }
.credit-info, .alert { padding: 15px; border-radius: 8px; margin-bottom: 25px; border: 1px solid transparent; width: 100%; box-sizing: border-box; }
.credit-info { background-color: var(--info-bg); border-color: var(--info-border); color: var(--info-text); text-align: center; font-size: 1.1em; }
.alert.alert-warning { background-color: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); display: flex; justify-content: center; align-items: center; }

/* --- 6. Page-Specific Styles --- */
.page-container { max-width: 1360px; margin: 20px auto; padding: 0 20px; }
.welcome-banner { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: #fff; padding: 25px; border-radius: 8px; margin-bottom: 25px; width: 100%; box-sizing: border-box; }
.welcome-banner h2 { margin: 0 0 10px 0; }
.generator-wrapper { display: grid; grid-template-columns: 1fr 1.5fr; gap: 30px; width: 100%; }
.form-container, .output-container { background: var(--container-bg); padding: 25px; border-radius: 8px; box-shadow: 0 4px 10px var(--shadow-color); border: 1px solid var(--border-color); }
.form-container h3, .output-container h3 { margin-top: 0; border-bottom: 2px solid var(--primary-color); padding-bottom: 10px; margin-bottom: 20px; }
.form-row { display: flex; gap: 20px; }
.form-row .form-group { flex: 1; }
.btn-submit .loader { width: 18px; height: 18px; border: 2px solid #FFF; border-bottom-color: transparent; border-radius: 50%; display: inline-block; box-sizing: border-box; animation: rotation 1s linear infinite; }
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
#result-placeholder { min-height: 400px; display: flex; align-items: center; justify-content: center; color: var(--text-color-light); background-color: var(--background-color); border-radius: 5px; border: 2px dashed var(--border-color); }
.tabs { border-bottom: 1px solid var(--border-color); margin-bottom: 15px; flex-shrink: 0; padding: 0 10px; }
.tab-link { background-color: transparent; float: right; border: 1px solid transparent; border-bottom: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; font-size: 17px; border-radius: 5px 5px 0 0; color: var(--text-color-light); }
.tab-link:hover { background-color: var(--background-color); }
.tab-link.active { background-color: var(--container-bg); color: var(--text-color); font-weight: bold; border-color: var(--border-color); transform: translateY(1px); }
.tab-content { display: none; padding: 6px 12px; line-height: 1.8; }
#preview-tab, #modal-preview-tab { direction: rtl; text-align: right; }
#preview-tab h1, #preview-tab h2, #modal-preview-tab h1, #modal-preview-tab h2 { color: var(--primary-color); }
.btn-copy { padding: 10px 15px; background-color: var(--secondary-color); border: none; color: #fff; cursor: pointer; border-radius: 5px; margin-top: 10px; font-weight: bold; }
.profile-page h1 { text-align: center; margin-bottom: 30px; }
.profile-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 30px; }
.profile-box { background: var(--container-bg); padding: 25px; border-radius: 8px; box-shadow: 0 4px 10px var(--shadow-color); border: 1px solid var(--border-color); }
.profile-box h3 { margin-top: 0; border-bottom: 2px solid var(--primary-color); padding-bottom: 10px; margin-bottom: 20px; }
.subscription-status p { font-size: 1.1em; margin: 10px 0; }
.subscription-status .btn { margin-top: 15px; }
.articles-table { width: 100%; border-collapse: collapse; background: var(--container-bg); border-radius: 8px; overflow: hidden; box-shadow: 0 4px 10px var(--shadow-color); border: 1px solid var(--border-color); }
.articles-table th, .articles-table td { padding: 15px; text-align: right; border-bottom: 1px solid var(--border-color); }
.articles-table thead { background-color: var(--primary-color); color: #fff; }
.articles-table tbody tr:last-child td { border-bottom: none; }
.articles-table tbody tr:hover { background-color: var(--background-color); }
.btn-view-article { background-color: var(--secondary-color); color: #fff; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-weight: bold; }
.pricing-page .pricing-header { text-align: center; margin-bottom: 50px; }
.pricing-page .pricing-header h1 { font-size: 2.5em; margin-bottom: 10px; }
.pricing-page .pricing-header p { font-size: 1.2em; color: var(--text-color-light); }
.plan-category-title { text-align: center; font-size: 1.8em; margin: 40px 0 20px 0; border-bottom: 2px solid var(--primary-color); display: inline-block; padding-bottom: 10px; }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.pricing-card { background: var(--container-bg); border-radius: 10px; box-shadow: 0 5px 15px var(--shadow-color); padding: 30px; text-align: center; transition: transform 0.3s, box-shadow 0.3s; border: 1px solid var(--border-color); }
.pricing-card:hover { transform: translateY(-10px); box-shadow: 0 10px 25px var(--shadow-color); }
.pricing-card h3 { font-size: 1.4em; margin-bottom: 20px; }
.pricing-card .price { font-size: 2.25em; font-weight: 700; color: var(--primary-color); margin-bottom: 20px; }
.pricing-card .price span { font-size: 0.5em; font-weight: 400; }
.pricing-card ul { list-style: none; padding: 0; margin: 0 0 30px 0; }
.pricing-card ul li { padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.pricing-card ul li:last-child { border-bottom: none; }
.btn-purchase { width: 100%; padding: 12px; background: var(--primary-color); color: #fff; border: none; border-radius: 5px; font-size: 1.1em; font-weight: 700; cursor: pointer; transition: background-color 0.3s; }
.btn-purchase:hover { background-color: #3a7ac8; }
html.dark-mode .btn-purchase:hover { background-color: #7ab5ff; }
.btn-purchase:disabled { background-color: var(--disabled-bg); cursor: not-allowed; color: var(--text-color); }
.manual-payment-page { max-width: 800px; }
.manual-payment-page > p { background-color: var(--info-bg); padding: 15px; border-radius: 8px; line-height: 1.8; color: var(--info-text); border: 1px solid var(--info-border); }
.bank-cards-list { margin: 30px 0; }
.bank-cards-list h3 { border-bottom: 2px solid var(--primary-color); padding-bottom: 10px; }
.bank-card { background: var(--container-bg); padding: 20px; border-radius: 8px; margin-bottom: 15px; box-shadow: 0 2px 5px var(--shadow-color); border: 1px solid var(--border-color); }
.bank-card div { margin-bottom: 8px; font-size: 1.1em; }
.bank-card .ltr-input { direction: ltr; display: inline-block; font-weight: bold; letter-spacing: 2px; }
.receipt-form-container { background: var(--container-bg); padding: 25px; border-radius: 8px; box-shadow: 0 4px 10px var(--shadow-color); border: 1px solid var(--border-color); }
.receipt-form-container input[type="file"] { width: 100%; padding: 10px; border: 2px dashed var(--border-color); border-radius: 5px; background-color: var(--background-color); }
footer.main-footer {margin-bottom:20px; border: solid var(--border-color) 2px; box-shadow: var(--shadow-color) -2px -2px 7px 0px; padding: 10px; border-radius: 15px; background: var(--background-color); justify-self: center;}
a.font-semibold.text-indigo-600.hover\:underline {color: var(--warning-text);}
/* --- 7. Modal Styles --- */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: var(--container-bg); align-items: center; justify-content: center; animation: fadeIn 0.3s; }
@keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} }
.modal-content { width: 100%; height: 100%; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 25px; border-bottom: 1px solid var(--border-color); background-color: var(--background-color); flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 1.2em; color: var(--primary-color); }
.close-btn { color: var(--text-color-light); font-size: 35px; font-weight: bold; cursor: pointer; line-height: 1; transition: color 0.2s; }
.close-btn:hover { color: var(--text-color); }
.modal-body { flex-grow: 1; overflow-y: hidden; display: flex; flex-direction: column; }
#modal-loader { display: flex; align-items: center; justify-content: center; flex-grow: 1; }
#modal-article-content { display: none; flex-grow: 1; flex-direction: column; height: 100%; }
.modal-tab-content { display: none; flex-grow: 1; overflow-y: auto; padding: 25px; }
.modal-tab-content.active { display: block; }
#modal-html-code { width: 100%; height: 100%; box-sizing: border-box; border: none; resize: none; padding: 0; font-family: monospace, "Courier New"; font-size: 14px; line-height: 1.5; direction: ltr; text-align: left; background-color: var(--container-bg); color: var(--text-color); }
#modal-html-code:focus { outline: none; }

/* --- 8. MOBILE RESPONSIVENESS --- */
.hamburger-menu {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    padding: 0 8px;
}

@media (max-width: 992px) {
    .generator-wrapper {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-top {
        width: 100%;
        margin-bottom: 10px;
    }
    .hamburger-menu {
        display: block;
    }
    .main-nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        background-color: var(--container-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        box-shadow: 0 4px 10px var(--shadow-color);
    }
    .main-nav-links.active {
        display: flex;
    }
    .main-nav-links .nav-link,
    .main-nav-links .profile-menu {
        width: 100%;
        text-align: right;
        padding: 15px;
        box-sizing: border-box;
        border-bottom: 1px solid var(--border-color);
        margin: 0;
    }
    .main-nav-links .btn {
        margin: 10px;
        text-align: center;
        display: block;
    }
    .main-nav-links .profile-menu {
        border-bottom: none;
    }
    .profile-menu .dropdown-content {
        position: static;
        display: block;
        box-shadow: none;
        border: none;
        background-color: transparent;
        min-width: unset;
    }
    .profile-menu .dropdown-content a {
        padding: 10px 15px;
        border-top: 1px solid var(--border-color);
    }
    .profile-menu > .profile-name {
        padding: 0 15px;
        display: block;
    }
    
    .page-container {
        padding: 0 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .profile-container {
        grid-template-columns: 1fr;
    }
    .articles-table {
        border: none;
        box-shadow: none;
    }
    .articles-table thead {
        display: none;
    }
    .articles-table, .articles-table tbody, .articles-table tr, .articles-table td {
        display: block;
        width: 100%;
    }
    .articles-table tr {
        margin-bottom: 15px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
    }
    .articles-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid var(--border-color);
    }
    .articles-table td:last-child {
        border-bottom: none;
    }
    .articles-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        width: 45%;
        padding-right: 10px;
        font-weight: bold;
        text-align: left;
        color: var(--text-color);
    }
}