/* Reset et configuration RTL */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    direction: rtl;
    text-align: right;
}

:root {
    --primary-color: #2c5f2d;
    --secondary-color: #f4f4f4;
    --accent-color: #ff6b35;
    --text-color: #333333;
    --border-color: #ddd;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Navigation */
.navbar {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--white);
    transition: 0.3s;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin-top: 0;
}

.nav-menu li a {
    color: var(--white);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
    padding: 0.5rem 0;
    display: block;
}

.nav-menu li a:hover {
    opacity: 0.8;
}

/* Responsive menu */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
        padding: 0.5rem;
        z-index: 1001;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        gap: 0;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        width: 100%;
    }

    .nav-menu.active {
        display: flex;
        animation: slideDown 0.3s ease-out;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu li a {
        padding: 1rem 0;
        display: block;
        width: 100%;
        transition: background-color 0.3s;
    }

    .nav-menu li a:hover {
        background-color: rgba(255, 255, 255, 0.1);
        padding-right: 0.5rem;
    }

    .nav-menu li[style*="margin-right"] {
        margin-right: 0 !important;
        border-right: none !important;
        padding-right: 0 !important;
        border-top: 2px solid rgba(255, 255, 255, 0.2);
        padding-top: 0.5rem;
        margin-top: 0.5rem;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Flash Messages */
.flash-message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    font-family: 'Cairo', sans-serif;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: #1e4520;
}

.btn-danger {
    background-color: var(--accent-color);
    color: var(--white);
}

.btn-danger:hover {
    background-color: #e55a2b;
}

.btn-secondary {
    background-color: #6c757d;
    color: var(--white);
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Cards */
.card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary-color);
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--secondary-color);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 600;
}

/* Animal Grid */
.animal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.animal-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s;
}

.animal-card:hover {
    transform: translateY(-5px);
}

.animal-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--secondary-color);
}

.animal-info {
    padding: 1rem;
}

.animal-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.animal-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.animal-details {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.animal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: 'Cairo', sans-serif;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Table */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table th,
.table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--primary-color);
    color: var(--white);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: var(--secondary-color);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Search and Filter */
.search-filter {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* Footer */
.footer {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 2rem 0;
    text-align: center;
    margin-top: auto;
}

/* Responsive - Tablettes */
@media (min-width: 769px) and (max-width: 1024px) {
    .animal-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .container {
        padding: 0 15px;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .page-title {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .animal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .animal-image {
        height: 150px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .search-filter {
        flex-direction: column;
    }

    .table {
        font-size: 0.875rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .card {
        padding: 1rem;
    }

    .page-header {
        gap: 0.75rem;
    }

    .nav-menu li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .main-content {
        padding: 1rem 0;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        width: 100%;
    }

    .btn-small {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.9rem;
    }

    .animal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .animal-image {
        height: 140px;
    }

    .animal-info {
        padding: 0.6rem;
    }

    .animal-number {
        font-size: 1rem;
    }

    .animal-details {
        font-size: 0.75rem;
    }

    .animal-actions {
        flex-direction: column;
    }

    .animal-actions .btn {
        width: 100%;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .card-header {
        font-size: 1.1rem;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 100%;
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.4rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-control {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
}

/* Utility Classes */
.text-center {
    text-align: center !important;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

/* Amélioration des zones tactiles pour mobile */
@media (hover: none) and (pointer: coarse) {
    .btn, .page-link, .nav-menu li a, .table-actions a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .form-control, select {
        min-height: 44px;
    }
}

/* ============================================
   PAGINATION STYLES - نمط الصفحات
   ============================================ */

.pagination-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 3rem auto;
    padding: 2rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(44, 95, 45, 0.1);
    max-width: 900px;
    gap: 1.5rem;
}

.pagination-info {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
    background: var(--secondary-color);
    padding: 0.75rem 2rem;
    border-radius: 25px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pagination {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.page-item {
    display: inline-block;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    min-width: 50px;
    min-height: 50px;
    text-align: center;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.page-link:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e4520 100%);
    color: var(--white);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(44, 95, 45, 0.3);
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e4520 100%);
    color: var(--white);
    border-color: var(--primary-color);
    cursor: default;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(44, 95, 45, 0.4);
}

.page-item.active .page-link:hover {
    transform: scale(1.1);
}

.page-item.disabled .page-link {
    cursor: not-allowed;
    opacity: 0.4;
    background: #f5f5f5;
    color: #999;
    border-color: #e0e0e0;
}

.page-item.disabled .page-link:hover {
    transform: none;
    background: #f5f5f5;
    color: #999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Boutons de navigation spéciaux (première, dernière) */
.page-item:first-child .page-link,
.page-item:last-child .page-link {
    font-size: 1.3rem;
    font-weight: 800;
    min-width: 55px;
}

/* Points de suspension */
.page-item.disabled .page-link {
    border: none;
    background: transparent;
    box-shadow: none;
    font-size: 1.5rem;
    padding: 0.5rem;
    min-width: 30px;
}

/* Animation au chargement */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pagination-container {
    animation: fadeInUp 0.5s ease-out;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-container {
        padding: 1.5rem 1rem;
        margin: 2rem auto;
    }
    
    .pagination-info {
        font-size: 1rem;
        padding: 0.6rem 1.5rem;
    }
    
    .pagination {
        gap: 0.5rem;
    }
    
    .page-link {
        padding: 0.6rem 0.8rem;
        min-width: 45px;
        min-height: 45px;
        font-size: 1rem;
    }
    
    .page-item:first-child .page-link,
    .page-item:last-child .page-link {
        font-size: 1.2rem;
        min-width: 48px;
    }

    /* Styles pour page d'achat */
    .purchase-table-container {
        margin: 0 -1rem;
        padding: 0;
    }

    .purchase-table thead {
        display: none;
    }

    .purchase-table tbody tr {
        display: block;
        margin-bottom: 1.5rem;
        border: 2px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 1rem;
        background: var(--white);
    }

    .purchase-table tbody tr td {
        display: block;
        padding: 0.5rem 0;
        border: none;
        text-align: right;
    }

    .purchase-table tbody tr td::before {
        content: attr(data-label);
        font-weight: 700;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--primary-color);
    }

    .purchase-table tbody tr td:nth-child(1)::before { content: "الصنف"; }
    .purchase-table tbody tr td:nth-child(2)::before { content: "الوحدة"; }
    .purchase-table tbody tr td:nth-child(3)::before { content: "الكمية"; }
    .purchase-table tbody tr td:nth-child(4)::before { content: "السعر للوحدة"; }
    .purchase-table tbody tr td:nth-child(5)::before { content: "المجموع"; }
    .purchase-table tbody tr td:nth-child(6)::before { content: "ملاحظة"; }
    .purchase-table tbody tr td:nth-child(7)::before { content: ""; }

    .purchase-table tbody tr td:last-child {
        text-align: center;
        padding-top: 1rem;
        margin-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    .purchase-table tfoot tr {
        display: block;
    }

    .purchase-table tfoot tr td {
        display: block;
        padding: 0.75rem 0;
        text-align: center;
    }

    .purchase-table tfoot tr:last-child td:first-child {
        display: none;
    }

    .purchase-table tfoot tr:last-child td:nth-child(2) {
        display: block;
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--primary-color);
    }

    .purchase-table tfoot tr:last-child td:nth-child(2)::before {
        content: "الإجمالي: ";
        display: inline;
    }

    .purchase-table .btn-danger {
        width: 100%;
        max-width: 200px;
    }

    .form-actions {
        flex-direction: column;
        margin-top: 1.5rem;
    }

    .form-actions .btn {
        width: 100%;
    }

    #addLine {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .purchase-table-container {
        margin: 0 -0.5rem;
    }

    .purchase-table tbody tr {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .form-row {
        gap: 0.75rem;
    }

    .purchase-table select.form-control,
    .purchase-table input.form-control {
        font-size: 1rem;
        padding: 0.75rem;
    }

    .purchase-table tbody tr td {
        padding: 0.75rem 0;
    }

    .purchase-table tbody tr td .form-control {
        width: 100%;
    }
}
