/*
 * Earth Link Root - Debt Management System Styles
 *
 * This file contains base styles, layout, and responsive adjustments.
 */

:root {
    --primary-color: #00796B; /* Earthlink Blue */
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --bg-light: #f8f9fa;
    --border-color: #e6e9ee;
    --font-family: 'Arial', sans-serif;
}

/* ** 1. Base Styles and Typography ** */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-light);
    color: #343a40;
    line-height: 1.6;
    direction: rtl; /* RTL Support */
    text-align: right;
    min-height: 100vh;
}

.container {
    width: 95%;
    max-width: 1200px;
    margin-right: auto;
    margin-left: auto;
    padding: 15px;
}

/* ** 2. Header and Navigation ** */

.topbar {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.logo {
    display: flex;
    align-items: center;
}

.logo svg {
    width: 35px;
    height: 35px;
    fill: white;
    margin-left: 10px;
}

.company {
    font-size: 1.4rem;
    font-weight: bold;
}

.nav a {
    color: white;
    text-decoration: none;
    padding: 5px 8px;
    margin: 0 3px; /* مسافة أصغر بين الروابط */
    font-size: 0.95rem;
    transition: background-color 0.2s;
    white-space: nowrap; /* منع انقسام الروابط */
}

.nav a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ** 3. Forms and Inputs (تعديل حقول الإدخال) ** */

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

main.center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px); /* ارتفاع الشاشة مطروحاً منه الهيدر والفوتر */
    padding: 20px;
}

main.center .card {
    width: 100%;
    max-width: 400px;
}

form label {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 0.95rem;
}

form input,
form select {
    width: 100%;
    padding: 10px; /* زيادة حجم البادينغ ليتناسق مع حقل الرمز */
    margin-top: 5px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

form input:focus,
form select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.actions {
    margin-top: 20px;
}

/* ** 4. Buttons (تعديل أحجام أزرار التعديل) ** */

.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.2s, opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

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

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

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

/* ** تعديل حجم زر التعديل (small) ** */
.btn.small {
    padding: 6px 12px; /* أصغر قليلاً من الأزرار العادية */
    font-size: 0.85rem;
    margin: 2px 0;
}

/* ** 5. Tables and Layout ** */

.datatable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9rem;
}

.datatable th,
.datatable td {
    padding: 10px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.datatable th {
    background-color: #e9ecef;
    font-weight: 700;
    white-space: nowrap;
}

/* === [تعديل Flexbox النهائي لضمان التنظيم والمحاذاة لليمين] === */
.grid {
    display: flex; 
    flex-wrap: wrap;
    /* هذا يضمن أن الكاردات تتراصف لليمين (بداية السطر في RTL) */
    justify-content: flex-end; 
    gap: 10px; /* مسافة أقل */
    margin-top: 20px;
    padding: 0;
}

.grid > a,
.grid > div {
    /* flex-grow يضمن التساوي في المساحة */
    flex-grow: 1;
    /* 4 أعمدة على الشاشات الكبيرة */
    flex-basis: calc(25% - 10px); 
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-self: stretch;
}

/* media queries لضبط عدد الكاردات في الصف حسب عرض الشاشة */
@media (max-width: 1200px) {
    .grid > a,
    .grid > div {
        /* 3 أعمدة */
        flex-basis: calc(33.33% - 10px);
    }
}

@media (max-width: 768px) {
    .grid > a,
    .grid > div {
        /* 2 عمود */
        flex-basis: calc(50% - 10px);
    }
}

@media (max-width: 500px) {
    .grid > a,
    .grid > div {
        /* عمود واحد */
        flex-basis: 100%;
    }
}
/* ======================================= */

.big {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-top: 5px;
}

.error, .success {
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-weight: 600;
}

.error {
    background-color: #f8d7da;
    color: var(--error-color);
    border: 1px solid #f5c6cb;
}

.success {
    background-color: #d4edda;
    color: var(--success-color);
    border: 1px solid #c3e6cb;
}

.muted {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

/* ** 6. Responsive Adjustments (للهواتف والأجهزة الصغيرة) ** */

@media (max-width: 900px) {
    /* ** شريط التنقل (Navigation) ** */
    .logo_row {
        flex-direction: column;
        align-items: flex-end; /* ليبقى الشعار على اليمين في RTL */
    }

    .nav {
        margin-top: 10px;
        display: flex;
        flex-wrap: wrap; /* السماح بتعدد الأسطر */
        justify-content: flex-end;
    }
    
    .nav a {
        margin: 5px 3px; /* مسافة أفضل بين الأزرار */
        font-size: 0.85rem;
        padding: 5px 7px;
    }

    /* ** الجداول (Tables) ** */
    .container {
        padding: 10px;
    }
    
    .datatable th {
        /* يمكن أن يبقى هذا الكود لتثبيت العنوان */
        position: sticky;
        right: 0; 
        background-color: #e9ecef;
        z-index: 10;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}