/* assets/css/style.css — هم‌خوان با UI Guide ارزیاب‌یار */

:root {
    --brand-teal: #199baa;
    --brand-teal-hover: #178d9a;
    --brand-teal-dark: #147f8d;
    --brand-accent: #0090a1;
    --brand-accent-light: #4cb1bd;
    --bg-surface: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-soft-green: #f6faf9;
    --border-green: #dceae6;
    --border-muted: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --primary-color: #2563eb;
    --success-color: #10b981;
    --success-text: #247f46;
    --danger-color: #ef4444;
    --danger-strong: #dc2626;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --spacing-std: 15px;
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.12);
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    font-family: IRANSans, Tahoma, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
}

.main-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 1rem;
}

.content-wrapper {
    padding: 24px 16px;
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

/* صفحه ورود — مرکزچین */
body.arzyabyar-auth-active #app-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 100vh;
    padding: 24px 16px;
}

.arzyabyar-auth-wrap {
    padding: 0;
    max-width: 100%;
}

@media (min-width: 576px) {
    .auth-card {
        max-width: 440px;
    }

    .dashboard-card {
        max-width: 800px;
    }
}

/* کارت پنل (الگوی مودال افزونه) */
.arzyabyar-panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-green);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    width: 100%;
    overflow: hidden;
}

.arzyabyar-panel-header {
    background: #f3f4f6;
    border-bottom: 1px solid #ddebe9;
    padding: 16px 24px;
}

.arzyabyar-auth-header {
    padding: 20px 24px 16px;
}

.arzyabyar-panel-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-accent);
}

.arzyabyar-panel-body {
    padding: 24px;
}

.app-logo {
    max-width: 160px;
    height: auto;
}

/* فیلدهای فرم لاگین */
.arzyabyar-login-field {
    margin-bottom: 1rem;
}

.arzyabyar-login-field label {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.arzyabyar-login-field input {
    width: 100%;
    border: 1px solid #e6e6e6;
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.arzyabyar-login-field input::placeholder {
    color: #99a1af;
}

.arzyabyar-login-field input:focus {
    outline: none;
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 2px rgba(25, 155, 170, 0.2);
}

.arzyabyar-text-muted {
    color: var(--text-secondary);
    font-size: 14px;
}

.arzyabyar-form-hint {
    color: var(--text-light);
    font-size: 13px;
}

/* دکمه اصلی */
.arzyabyar-btn-primary,
.btn-primary {
    background: var(--brand-teal);
    color: #fff;
    border: 1px solid var(--brand-teal);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.arzyabyar-btn-primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
    background: var(--brand-teal-hover);
    border-color: var(--brand-teal-hover);
    box-shadow: 0 3px 10px rgba(25, 155, 170, 0.35);
    transform: translateY(-1px);
    color: #fff;
}

.arzyabyar-btn-primary:active:not(:disabled),
.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
}

.arzyabyar-btn-primary:disabled,
.btn-primary:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    opacity: 0.75;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.form-switch-link {
    cursor: pointer;
    color: var(--brand-accent);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.form-switch-link:hover {
    color: var(--brand-teal);
    text-decoration: underline;
}

#alert-placeholder .alert-danger,
.arzyabyar-login-error {
    background: hsl(359, 100%, 97%);
    border: 1px solid #fecaca;
    color: var(--danger-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.arzyabyar-spinner {
    color: var(--brand-teal) !important;
}

.text-primary {
    color: var(--brand-teal) !important;
}

/* 8. Spinner Overlay */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

/* ==================== STYLES FOR FIXED HEADER ==================== */

/* --- Header Container --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid #ddebe9;
    padding: 0.75rem 1.5rem;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
    height: 73px;
    /* NEW: Define a fixed height for calculation */
}

/* --- Header Content Wrapper --- */
.app-header .header-content {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

#logout-btn {
    order: 1;
    flex-shrink: 0;
}

.header-center {
    order: 2;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1.95rem;
}

.header-start-slot {
    order: 3;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.header-logo-img {
    height: 40px;
    width: auto;
    border-radius: 5px;
}

/* --- Header Logo --- */
.app-header .header-logo {
    height: 40px;
    width: auto;
}

/* --- Wrapper for Header Buttons --- */
.app-header .header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- Base Style for Header Buttons --- */
.app-header .header-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: 1px solid #ced4da;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    color: #495057;
    transition: all 0.2s ease-in-out;
}

/* --- Hover effect for General Buttons --- */
.app-header .header-button:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
}

#back-to-menu-btn {
    border-color: var(--brand-teal);
    color: var(--brand-teal);
}

#back-to-menu-btn:hover {
    background-color: var(--brand-teal);
    color: #fff;
    border-color: var(--brand-teal);
}

.app-header .btn-danger,
#logout-btn {
    background-color: transparent;
    border-color: var(--danger-strong);
    color: var(--danger-strong);
}

.app-header .btn-danger:hover,
#logout-btn:hover {
    background-color: var(--danger-strong);
    color: #fff;
    border-color: var(--danger-strong);
}

#global-tariff-year {
    width: auto;
    min-width: 120px;
    border-color: #ddebe9;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

#global-tariff-year:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 2px rgba(25, 155, 170, 0.2);
}

/* --- Body Padding for Fixed Header --- */
body.auth-active {
    padding-top: 73px;
    /* MODIFIED: Match the exact header height */
}

/* --- Spinner --- */
#loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#loading-spinner .spinner-border {
    color: #fff !important;
    width: 3rem;
    height: 3rem;
}

#loading-spinner.d-none {
    display: none !important;
}

/* ==================== STYLES FOR MENU PAGE ==================== */

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    text-decoration: none;
    color: #343a40;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.menu-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(25, 155, 170, 0.12);
    background-color: #ffffff;
    border-color: var(--brand-accent-light);
}

.menu-icon-wrapper {
    flex-shrink: 0;
    background: #eef9fa;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-green);
}

.menu-icon {
    font-size: 1.75rem;
    color: var(--brand-teal);
}

.menu-text {
    display: flex;
    flex-direction: column;
}

.menu-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: #212529;
}

.menu-description {
    font-size: 0.9rem;
    color: #6c757d;
    margin: 0;
}

/* --- Styles for Disabled Menu Item --- */
.menu-item.disabled {
    background-color: rgba(230, 230, 230, 0.6);
    cursor: not-allowed;
    color: #999;
    box-shadow: none;
}

.menu-item.disabled:hover {
    transform: none;
    border-color: rgba(255, 255, 255, 0.4);
    background-color: rgba(230, 230, 230, 0.6);
}

.menu-item.disabled .menu-icon-wrapper {
    background: #e9ecef;
}

.menu-item.disabled .menu-icon {
    color: #adb5bd;
}

.menu-item.disabled .menu-title {
    color: #6c757d;
}

.menu-item.disabled .menu-description {
    color: #999;
}


/* ===================================================================== */
/*   NEW & MODIFIED STYLES FOR FULLSCREEN IFRAME & RESPONSIVENESS        */
/* ===================================================================== */

/* --- NEW: Style for the iframe container for full-screen behavior --- */
#app-container {
    width: 100vw;
    /* Occupy 100% of the viewport width */
    height: calc(100vh - 73px);
    /* Occupy 100% of viewport height minus the header's height */
    margin-top: 0;
}

#app-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    /* Remove default iframe border */
    display: block;
    /* Remove any potential bottom space */
}

/* --- MODIFIED: Remove body padding ONLY when an iframe is loaded --- */
/* This removes all top space, as the iframe container now handles its own position */
body.auth-active:has(#app-container > iframe) {
    padding-top: 70px;
    /* Ensure body content starts below the fixed header */
    overflow: hidden;
    /* Prevent scrolling on the body when iframe is active */
}

/* Make sure the container holding the iframe is positioned correctly */
body.auth-active:has(#app-container > iframe) .main-container {
    /* Align container to the top, right below the header's padding space */
    align-items: flex-start;
}

/* --- For large screens (Desktop), disable body scrolling unless specified --- */
@media (min-width: 768px) {
    body:not(.arzyabyar-auth-active) {
        overflow: hidden;
    }
}

body.arzyabyar-auth-active {
    overflow-y: auto;
}

/* مودال پروفایل */
#changePasswordModal .modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

#changePasswordModal .modal-title {
    font-weight: 700;
}

#profileModal .modal-header {
    background: #f3f4f6;
    border-bottom: 1px solid #ddebe9;
}

#profileModal .modal-title {
    color: var(--brand-accent);
    font-weight: 700;
    font-size: 18px;
}

#profileModal .modal-content {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-green);
    overflow: hidden;
}

#profileModal .form-control:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 2px rgba(25, 155, 170, 0.2);
}

#change-profile-image-btn {
    color: var(--brand-accent);
}

/* --- For small screens (Mobile/Tablet), enable scrolling FOR NON-IFRAME PAGES --- */
@media (max-width: 767px) {

    /* Allow scrolling for pages like login or menu */
    body:not(:has(#app-container > iframe)) {
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Keep body scroll locked when iframe is shown */
    body:has(#app-container > iframe) {
        overflow: hidden;
    }

    /* Add some vertical space on mobile for better layout on NON-IFRAME pages */
    .main-container:not(:has(#app-container > iframe)) {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}


/* ==================== MOBILE RESPONSIVE STYLES FOR HEADER BUTTONS ==================== */

.d-none {
    display: none !important;
}

@media (max-width: 768px) {

    /* Hide the text inside header buttons */
    .header-button span {
        display: none;
    }

    /* Adjust padding and gap for icon-only buttons */
    .header-button {
        gap: 0;
        padding: 0.5rem 0.75rem;
    }

    /* Make the icon slightly larger for easier tapping */
    .header-button i {
        font-size: 1.2rem;
    }

    /* Adjust header height and padding for mobile */
    .app-header {
        height: 60px;
        /* A slightly smaller header on mobile */
        padding: 0.5rem 1rem;
    }

    /* Adjust body padding and iframe height for new mobile header height */
    body.auth-active {
        padding-top: 60px;
    }

    #app-container {
        height: calc(100vh - 60px);
    }
}




/* ============================================= */
/*       STYLES FOR PROFILE (IMAGE ONLY)         */
/* ============================================= */

/* --- Container for the profile image in the header --- */
.welcome-container {
    display: flex;
    align-items: center;
}

/* --- Hide the welcome text as requested --- */
.welcome-text {
    display: none;
}

/* --- Profile image style in the header (Desktop & Mobile) --- */
.header-profile-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    /* Makes the image circular */
    object-fit: cover;
    /* Prevents image stretching */
    border: 2px solid #e0e0e0;
    /* A subtle border for better contrast */
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease;
    /* No margin needed as the text is hidden */
}

.header-profile-img:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-profile-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--brand-teal);
    background: rgba(25, 155, 170, 0.12);
    color: var(--brand-teal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.header-profile-icon-btn:hover {
    background: var(--brand-teal);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(25, 155, 170, 0.35);
}

.profile-avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--brand-teal);
    background: rgba(25, 155, 170, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-avatar-placeholder {
    font-size: 2.75rem;
    color: var(--brand-teal);
}

/* --- Profile image style in the Profile Edit Modal --- */
.profile-image-modal {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 15px auto;
    /* Center the image and add bottom margin */
    display: block;
    border: 4px solid #dee2e6;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

#change-profile-image-btn {
    text-decoration: none;
    font-weight: 500;
}

/* ================================================= */
/*       MOBILE OPTIMIZATIONS (Responsive)         */
/* ================================================= */

/* --- For tablets and mobile devices (max-width: 767px) --- */
@media (max-width: 767px) {

    /* Slightly reduce the size of the profile image in the header for smaller screens */
    .header-profile-img,
    .header-profile-icon-btn {
        width: 36px;
        height: 36px;
    }

    /* Reduce the size of the profile image in the modal */
    .profile-image-modal {
        width: 100px;
        height: 100px;
    }
}





/* ===================================================================== */
/*   iOS Safe Area Adjustments (for Notch support)                     */
/*   این کد را به انتهای فایل style.css اضافه کنید                       */
/* ===================================================================== */

/* --- تنظیمات برای دسکتاپ و دستگاه‌های بدون ناچ --- */

/* 1. تنظیم ارتفاع هدر و فاصله داخلی بالای آن با در نظر گرفتن ناچ */
.app-header {
    /* ارتفاع نهایی هدر = ارتفاع پایه + فاصله امن بالای صفحه */
    height: calc(73px + env(safe-area-inset-top));

    /* فاصله داخلی بالای هدر = فاصله پایه + فاصله امن بالای صفحه */
    padding-top: calc(0.75rem + env(safe-area-inset-top));
}

/* 2. تنظیم فاصله بدنه اصلی صفحه برای جلوگیری از رفتن زیر هدر */
body.auth-active {
    /* فاصله بالای بدنه = ارتفاع پایه هدر + فاصله امن بالای صفحه */
    padding-top: calc(73px + env(safe-area-inset-top));
}

/* 3. تنظیم ارتفاع کانتینر iframe */
#app-container {
    /* ارتفاع کانتینر = ارتفاع کل صفحه - (ارتفاع پایه هدر + فاصله امن بالای صفحه) */
    height: calc(100vh - (73px + env(safe-area-inset-top)));
}


/* --- تنظیمات برای موبایل و تبلت (صفحه‌های کوچکتر از 768 پیکسل) --- */
@media (max-width: 768px) {

    /* 1. بازنویسی تنظیمات هدر برای موبایل */
    .app-header {
        height: calc(60px + env(safe-area-inset-top));
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }

    /* 2. بازنویسی تنظیمات بدنه اصلی برای موبایل */
    body.auth-active {
        padding-top: calc(60px + env(safe-area-inset-top));
    }

    /* 3. بازنویسی تنظیمات کانتینر iframe برای موبایل */
    #app-container {
        height: calc(100vh - (60px + env(safe-area-inset-top)));
    }
}