/* assets/css/style.css - FINAL CONSOLIDATED VERSION */

/* 1. Import Vazirmatn Font */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* 2. CSS Reset and Basic Styles */
:root {
    --primary-color: #0056b3; /* A modern blue */
    --background-color: #f4f7f6;
    --text-color: #333;
    --container-bg: #ffffff;
    --border-radius: 8px;
    --box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

* {
    font-family: 'Vazirmatn', verdana, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Vazirmatn', verdana, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    direction: rtl;
}

/* 3. Layout and Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--container-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* 4. Navigation Bar */
.navbar {
    background-color: var(--container-bg);
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.navbar .logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}
.navbar a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s;
}
.navbar a:hover {
    background-color: #e9ecef;
}

/* 5. Forms and Buttons */
.form-wrapper {
    max-width: 450px;
    margin: 2rem auto;
    padding: 2rem;
    background: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
}
.form-wrapper h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: 'Vazirmatn', sans-serif;
}
.btn {
    display: block;
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: 5px;
    background-color: var(--primary-color);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: 'Vazirmatn', verdana, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.btn:hover {
    background-color: #004494;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* 6. Dashboard Styles */
.dashboard-welcome {
    text-align: center;
    padding: 1rem;
    background-color: #e9ecef;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}
.dashboard-menu h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}
.menu-item {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.menu-item h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}
.menu-item a {
    display: block;
    background-color: #fff;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: #0056b3;
    border: 1px solid #ccc;
    border-radius: 5px;
    transition: all 0.3s ease;
}
.menu-item a:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: #004494;
    transform: translateX(-5px);
}

/* 7. Messages and Tables */
.message {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}
.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.item-form {
    background: #fdfdfd;
    border: 1px solid #e9ecef;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
}
.item-form h3 {
    margin-bottom: 1rem;
}
.form-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.form-row input, .form-row select {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.btn-add {
    padding: 0.5rem 1.5rem;
    border: none;
    background-color: #28a745;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-add:hover {
    background-color: #218838;
}
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}
.items-table th, .items-table td {
    border: 1px solid #dee2e6;
    padding: 0.75rem;
    text-align: right;
}
.items-table thead {
    background-color: #f1f5f8;
    color: #334e68;
    font-weight: bold;
}
.items-table tfoot {
    font-weight: bold;
}
.items-table td:first-child, .items-table td:nth-child(3), .items-table td:nth-child(4) {
    text-align: center;
}
.delete-icon {
    cursor: pointer;
    font-size: 1.2rem;
}

/* 8. Search Form */
.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: var(--border-radius);
}
.search-form .form-group {
    margin-bottom: 0;
    flex: 1 1 200px;
}
.btn-small {
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
    text-decoration: none;
    background-color: #6c757d;
    color: white;
    border-radius: 5px;
}
.btn-small:hover {
    background-color: #5a6268;
}

/* 9. Factor Edit Page */
.factor-info-box {
    display: flex;
    justify-content: space-around;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
}
.action-buttons {
    text-align: center;
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* 10. Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding: 1.5rem;
    color: #777;
    font-size: 0.9rem;
}

/* 11. Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
}
.pagination-list {
    display: flex;
    list-style-type: none;
    padding: 0;
    margin: 0;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.pagination-list li a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    background-color: #fff;
    color: var(--primary-color);
    border-left: 1px solid #dee2e6;
    transition: background-color 0.3s;
    cursor: pointer;
    font-size: 0.9rem;
}
.pagination-list li:first-child a {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}
.pagination-list li:last-child a {
    border-left: 0;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}
.pagination-list li a:hover {
    background-color: #f4f7f6;
}
.pagination-list li a.active {
    background-color: var(--primary-color);
    color: #fff;
    font-weight: bold;
    cursor: default;
}
.pagination-list li a.disabled {
    color: #aaa;
    pointer-events: none;
    background-color: #f8f9fa;
}


/* 12. Print and Invoice Styles */
@page {
    size: A4;
    margin: 0;
}

@media print {
    body, html {
        background: #fff;
    }
    body * {
        visibility: hidden;
    }
    #printable-invoice, #printable-invoice * {
        visibility: visible;
    }
    #printable-invoice {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block !important;
    }
    #edit-interface, .navbar, .footer, .no-print {
        display: none !important;
    }
}

.invoice-box {
    max-width: 800px;
    margin: auto;
    padding: 30px;
    border: 1px solid #eee;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
    font-size: 16px;
    line-height: 24px;
    color: #555;
    background: #fff;
    font-family: 'Vazirmatn', sans-serif !important;
}
/* Header centering */
.invoice-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}
.header-right {
    order: -1;
    margin-bottom: 1rem;
}
.header-right img {
    max-width: 100px;
}
.header-left h1 {
    font-size: 1.4em;
    color: #333;
    margin: 0;
}
.header-left p {
    margin: 2px 0;
    font-size: 0.9em;
    color: #777;
}

.invoice-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 30px;
    font-size: 0.9em;
}
.invoice-info span {
    font-weight: bold;
    color: #333;
    margin-left: 5px;
}
.invoice-table {
    width: 100%;
    line-height: inherit;
    text-align: right;
    border-collapse: collapse;
}
.invoice-table thead th {
    background: #f7f7f7;
    border-bottom: 2px solid #ddd;
    font-weight: bold;
    padding: 8px;
    color: #333;
}
.invoice-table tbody tr:nth-child(odd) {
    background: #fdfdfd;
}
.invoice-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}
.invoice-table tfoot td {
    font-weight: bold;
    background: #f7f7f7;
    border-top: 2px solid #ddd;
}
/* Footer changes */
.invoice-footer {
    text-align: left;
    margin-top: 30px;
    padding-top: 0;
    border-top: none;
}
.invoice-footer-logo img {
    max-width: 120px;
    margin-top: 1cm;
}

/* 13. Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .container, .form-wrapper {
        margin: 1rem;
        padding: 1rem;
    }
    .navbar {
        flex-direction: column;
        gap: 0.5rem;
    }
    .form-wrapper {
        max-width: 100% !important;
    }
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .search-form {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
    .search-form .form-group,
    .search-form .form-group select,
    .search-form .form-group input {
        width: 100%;
    }
    .btn {
        font-size: 1rem;
    }
    .items-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        border: 0;
    }
    .menu-grid {
        grid-template-columns: 1fr;
    }
    .factor-info-box {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}