/* RTL Support and Main Styles for Money Tracker Application */

body[dir="rtl"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
}

/* Filter Form Styles */
.filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    margin-bottom: 5px;
    font-weight: bold;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

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

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

/* Mobile-first responsive adjustments */
@media (max-width: 767px) {
    .filter-grid {
        gap: 10px;
    }
    
    .filter-group {
        margin-bottom: 8px;
    }
    
    .filter-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .filter-buttons button {
        width: 100%;
        padding: 10px;
        font-size: 16px;
    }
    
    input, select {
        padding: 12px;
        font-size: 16px;
    }
}

@media (min-width: 768px) {
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .filter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    overflow-x: hidden; /* منع التمرير الأفقي */
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box; /* ضمان عدم تجاوز العرض */
}

header {
    background-color: #333;
    color: white;
    padding: 10px 0;
}

/* تنسيقات الهيدر الجديدة */
.main-header {
    background-color: #333;
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
    /* overflow: hidden;  منع التمرير الأفقي - تم التعليق لاختبار القائمة المنسدلة */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    flex-wrap: wrap; /* السماح بالالتفاف عند الحاجة */
}

body[dir="rtl"] .header-content {
    flex-direction: row-reverse;
}

.page-title {
    display: block;
    padding-left: 10px;
    padding-bottom: 20px;
    font-size: 1.5em;
    font-weight: bold;
}

.main-nav {
    position: relative;
}

.main-nav .menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
}

.main-nav .menu ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-nav .menu ul li {
    margin-right: 0;
    margin-left: 20px;
}

.main-nav .menu ul li a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 3px;
    transition: background-color 0.3s;
}

.main-nav .menu ul li a:hover {
    background-color: rgba(255,255,255,0.1);
    text-decoration: none;
}

.content-container {
    padding-top: 20px;
}

/* تنسيقات التجاوب للأجهزة المحمولة */
@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
    }
    
    .page-title {
        margin-bottom: 10px;
        width: 100%;
        text-align: center;
    }
    
    .main-nav {
        width: 100%;
    }
    
    .main-nav .menu-toggle {
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
    
    .main-nav .menu {
        display: none;
        width: 100%;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background-color: #333;
        z-index: 100;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        border-radius: 0 0 5px 5px;
    }
    
    .main-nav .menu.active {
        display: block;
    }
    
    .main-nav .menu ul {
        flex-direction: column;
        padding: 10px;
    }
    
    .main-nav .menu ul li {
        margin: 0;
        text-align: center;
    }
    
    .main-nav .menu ul li a {
        display: block;
        padding: 10px;
        margin: 5px 0;
    }
    
    nav ul {
        margin-top: 10px;
        flex-direction: column;
    }

    /* Responsive table container */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Improve scrolling on touch devices */
    }

    /* Ensure table within responsive container doesn't overflow */
    .table-responsive table {
        width: 100%; /* Ensure table takes full width of container */
        max-width: none; /* Remove any max-width that might prevent shrinking */
        white-space: nowrap; /* Prevent text wrapping in cells */
    }
}

nav ul {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

body[dir="rtl"] nav ul li {
    margin-right: 20px;
    margin-left: 0;
}

body:not([dir="rtl"]) nav ul li {
    margin-left: 20px;
    margin-right: 0;
}

nav ul li a {
    color: white;
    text-decoration: none;
}

nav ul li a:hover {
    text-decoration: underline;
}

.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.card {
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 20px;
}

.card h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.stat-card {
    background-color: #f9f9f9;
    border-radius: 5px;
    padding: 15px;
    text-align: center;
}
.stat-card h3 {
    margin-top: 0;
    color: #333;
}
.stat-card p {
    font-size: 24px;
    font-weight: bold;
    margin: 10px 0 0;
    color: #4CAF50;
}
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
table th {
    background-color: #f2f2f2;
}
.active {
    color: green;
}
.inactive {
    color: red;
}
.btn {
    display: inline-block;
    background-color: #4CAF50;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    margin-right: 5px;
}
.btn:hover {
    background-color: #45a049;
}
.btn-danger {
    background-color: #f44336;
}
.btn-danger:hover {
    background-color: #d32f2f;
}
.user-info {
    margin-bottom: 20px;
}

/* Transaction form styles */
.transaction-types {
    display: flex;
    margin-bottom: 15px;
}
.transaction-type {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
}
.transaction-type.active {
    background-color: #e9e9e9;
    font-weight: bold;
    color: #4CAF50;
}
.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover {
    background-color: #5a6268;
}

/* Form styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-actions {
    margin-top: 20px;
}

.error-message {
    color: red;
    margin-bottom: 15px;
}

.success-message {
    color: green;
    margin-bottom: 15px;
}

/* User management styles */
.user-list {
    width: 100%;
}

.user-list th, 
.user-list td {
    padding: 10px;
}

.user-actions a {
    margin-right: 10px;
}

body[dir="rtl"] .user-actions a {
    margin-right: 0;
    margin-left: 10px;
}

/* Responsive styles */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
    }
    
    nav ul {
        margin-top: 10px;
    }

    /* Responsive table container */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Improve scrolling on touch devices */
    }

    /* Ensure table within responsive container doesn't overflow */
    .table-responsive table {
        width: 100%; /* Ensure table takes full width of container */
        max-width: none; /* Remove any max-width that might prevent shrinking */
        white-space: nowrap; /* Prevent text wrapping in cells */
    }
}

/* Header Menu Styles */
.header .menu-container {
    display: flex;
    align-items: center;
}

.header .menu-toggle {
    display: none; /* Hidden by default on desktop */
    background: none;
    border: none;
    color: #333; /* Adjust color as needed */
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 10px;
}

.header .menu ul {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.header .menu ul li {
    margin-left: 20px; /* Space between items for LTR */
}

body[dir="rtl"] .header .menu ul li {
    margin-left: 0;
    margin-right: 20px; /* Space between items for RTL */
}

.header .menu ul li a {
    text-decoration: none;
    color: #333; /* Adjust color as needed */
    font-weight: bold;
}

.header .menu ul li a:hover {
    text-decoration: underline;
}

/* Mobile styles for menu */
@media (max-width: 768px) {
    .header .menu-container {
        flex-direction: column;
        align-items: flex-start; /* Align menu items to the right in RTL */
    }

    body[dir="rtl"] .header .menu-container {
         align-items: flex-end; /* Align menu items to the left in LTR */
    }

    .header .menu-toggle {
        display: block; /* Show hamburger icon on mobile */
        align-self: flex-end; /* Align toggle to the right in LTR */
    }

     body[dir="rtl"] .header .menu-toggle {
        align-self: flex-start; /* Align toggle to the left in RTL */
    }

    .header .menu {
        display: none; /* Hide menu by default on mobile */
        width: 100%;
        text-align: center; /* Center text for collapsed menu */
    }

    .header .menu.active {
        display: block; /* Show menu when active */
    }

    .header .menu ul {
        flex-direction: column; /* Stack menu items vertically */
        width: 100%;
    }

    .header .menu ul li {
        margin: 10px 0; /* Add vertical space between stacked items */
        width: 100%;
    }

    body[dir="rtl"] .header .menu ul li {
        margin: 10px 0; /* Add vertical space between stacked items */
    }
}

/* New styles for header matching login.php */
.main-header {
    background: linear-gradient(135deg, #1E90FF, #0047AB);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: auto;
    padding: 20px;
    direction: rtl;
}

.login-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 1200px;
    overflow: hidden;
}

.login-header {
    background: #1E90FF;
    color: white;
    text-align: center;
    padding: 30px 20px;
}

.login-header h1 {
    font-size: 2.2rem;
    margin-bottom: 5px;
}

.login-header h2 {
    font-size: 1.2rem;
    font-weight: 400;
    opacity: 0.9;
}

.login-body {
    padding: 30px;
}

/* Adjust navigation for new header */
.main-nav {
    position: relative;
    margin-top: 0;
}

.main-nav .menu ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.main-nav .menu ul li {
    margin: 5px 10px;
}

.login-body .menu ul li a {
    color: #333;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.login-body .menu ul li a:hover {
    background-color: rgba(30, 144, 255, 0.1);
}

/* Make menu toggle visible on mobile */
.login-body .menu-toggle {
    color: #1E90FF;
}

/* Mobile styles */
@media (max-width: 768px) {
    .login-container {
        border-radius: 10px;
        overflow: visible; /* Allow menu to overflow container */
    }
    
    .login-header {
        padding: 25px 15px;
    }
    
    .login-body {
        padding: 25px 20px;
        position: relative; /* Create positioning context for menu */
    }
    
    /* Restore original mobile menu styles */
    .main-nav .menu-toggle {
        display: block;
        margin: 0 auto;
    }

    .main-nav .menu {
        display: none;
        width: 100%;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background-color: #333;
        z-index: 1000; /* Higher z-index to appear above content */
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        border-radius: 0 0 5px 5px;
    }

    .main-nav .menu.active {
        display: block;
    }

    .main-nav .menu ul {
        flex-direction: column;
        padding: 10px;
    }

    .main-nav .menu ul li {
        margin: 0;
        text-align: center;
    }

    .main-nav .menu ul li a {
        display: block;
        padding: 10px;
        margin: 5px 0;
        color: white;
    }
    
    .main-nav .menu ul li a:hover {
        background-color: rgba(255,255,255,0.1);
    }
}