/* style.css - النسخة الكاملة */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tahoma', 'Arial', sans-serif;
}

body {
    background: #f0f4fa;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===== شاشات تسجيل الدخول ===== */
.screen {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 420px;
}

.login-container h2 {
    text-align: center;
    color: #1f3a5f;
    margin-bottom: 30px;
    font-size: 28px;
}

.login-container input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 2px solid #e2ebf3;
    border-radius: 12px;
    font-size: 15px;
    transition: 0.3s;
}

.login-container input:focus {
    border-color: #2a7de1;
    outline: none;
    box-shadow: 0 0 0 4px rgba(42,125,225,0.1);
}

.login-container .btn-primary {
    width: 100%;
    padding: 14px;
    background: #1f3a5f;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}

.login-container .btn-primary:hover {
    background: #143049;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(31,58,95,0.3);
}

.login-container p {
    text-align: center;
    margin-top: 20px;
    color: #6c819c;
}

.login-container a {
    color: #2a7de1;
    text-decoration: none;
    font-weight: bold;
}

.login-container a:hover {
    text-decoration: underline;
}

/* ===== التطبيق الرئيسي ===== */
#appMain {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.container {
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}

h1 {
    text-align: center;
    color: #0b2b4a;
    margin-bottom: 20px;
    font-size: 28px;
    border-bottom: 2px solid #e6edf5;
    padding-bottom: 15px;
}

/* ===== التبويبات ===== */
.tab-menu {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-bottom: 2px solid #e6edf5;
    padding-bottom: 12px;
}

.tab-menu button {
    background: transparent;
    border: none;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #5d738b;
    cursor: pointer;
    border-radius: 30px;
    transition: 0.3s;
}

.tab-menu button:hover {
    background: #eef3f8;
    transform: translateY(-2px);
}

.tab-menu button.active {
    background: #1f3a5f;
    color: white;
    box-shadow: 0 4px 12px rgba(31,58,95,0.3);
}

/* ===== البطاقات ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: #f9fbfd;
    border-radius: 18px;
    padding: 20px;
    border: 1px solid #eef3f8;
    transition: 0.3s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.card h3 {
    margin-bottom: 16px;
    color: #1f3a5f;
    font-size: 18px;
    border-right: 4px solid #2a7de1;
    padding-right: 12px;
}

/* ===== الأرصدة ===== */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.balance-item {
    background: white;
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
    border: 1px solid #e2ebf3;
    transition: 0.3s;
}

.balance-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.balance-item .currency {
    font-size: 13px;
    color: #5d738b;
    font-weight: bold;
}

.balance-item .amount {
    font-size: 28px;
    font-weight: bold;
    color: #0b2b4a;
    margin: 6px 0;
}

.balance-item .initial {
    font-size: 12px;
    color: #8a9bb0;
}

.highlight-positive {
    color: #1e7b4c;
}

.highlight-negative {
    color: #b13e3e;
}

/* ===== الفورم ===== */
label {
    display: block;
    margin: 14px 0 5px;
    font-weight: 600;
    color: #2c405c;
    font-size: 14px;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #d6e0eb;
    border-radius: 12px;
    font-size: 15px;
    background: white;
    transition: 0.3s;
}

input:focus, select:focus, textarea:focus {
    border-color: #2a7de1;
    outline: none;
    box-shadow: 0 0 0 4px rgba(42,125,225,0.08);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

/* ===== الأزرار ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    display: inline-block;
}

.btn-primary {
    background: #1f3a5f;
    color: white;
}

.btn-primary:hover {
    background: #143049;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(31,58,95,0.3);
}

.btn-success {
    background: #1e7b4c;
    color: white;
}

.btn-success:hover {
    background: #13613b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30,123,76,0.3);
}

.btn-danger {
    background: #b13e3e;
    color: white;
}

.btn-danger:hover {
    background: #8f2f2f;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(177,62,62,0.3);
}

.btn-warning {
    background: #d49b2c;
    color: white;
}

.btn-warning:hover {
    background: #b88722;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212,155,44,0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid #1f3a5f;
    color: #1f3a5f;
}

.btn-outline:hover {
    background: #1f3a5f;
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.flex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* ===== الجداول ===== */
.table-wrap {
    overflow-x: auto;
    margin-top: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    background: #e9eff6;
    padding: 12px 10px;
    text-align: center;
    color: #1f3a5f;
    font-weight: bold;
    white-space: nowrap;
}

td {
    padding: 10px 8px;
    border-bottom: 1px solid #e6edf5;
    text-align: center;
    vertical-align: middle;
}

tr:hover td {
    background: #f8fafc;
}

/* ===== الصور ===== */
.img-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid #e2ebf3;
    transition: 0.3s;
}

.img-thumb:hover {
    transform: scale(1.1);
    border-color: #2a7de1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===== شارات ===== */
.badge {
    background: #e4ecf7;
    padding: 5px 14px;
    border-radius: 30px;
    font-size: 13px;
    color: #1f3a5f;
    display: inline-block;
    margin: 3px;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.status-badge {
    font-size: 11px;
    padding: 3px 12px;
    border-radius: 20px;
    display: inline-block;
}

.status-paid {
    background: #d4edda;
    color: #155724;
}

.status-unpaid {
    background: #f8d7da;
    color: #721c24;
}

.status-partial {
    background: #fff3cd;
    color: #856404;
}

/* ===== الديون ===== */
.debt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e2ebf3;
    margin-bottom: 8px;
    transition: 0.3s;
}

.debt-item:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.debt-item .debt-name {
    font-weight: bold;
    font-size: 15px;
}

.debt-item .debt-amount {
    font-size: 18px;
    font-weight: bold;
    color: #1f3a5f;
}

.debt-item .debt-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    margin: 0 4px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: 0.3s;
}

.debt-item .debt-actions button:hover {
    background: #eef3f8;
}

/* ===== الرصيد المبدئي ===== */
.initial-balance-input {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
    background: white;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid #e2ebf3;
}

.initial-balance-input label {
    margin: 0;
    min-width: 70px;
    font-weight: bold;
}

.initial-balance-input input {
    flex: 1;
    padding: 6px 12px;
}

/* ===== المودال ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(255,255,255,0.1);
}

.modal-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    background: none;
    border: none;
}

.modal-close:hover {
    color: #bbb;
    transform: scale(1.2);
}

/* ===== أنيميشن ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ===== تنسيقات الموبايل ===== */
@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 16px;
    }
    
    .balance-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .tab-menu button {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .login-container {
        padding: 24px;
        margin: 16px;
    }
}

@media (max-width: 600px) {
    .balance-item .amount {
        font-size: 22px;
    }
    
    .debt-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .debt-item .debt-actions {
        text-align: left;
    }
}

/* ===== عام ===== */
.mt-2 {
    margin-top: 20px;
}

.text-muted {
    color: #6c819c;
    font-size: 13px;
}

.text-center {
    text-align: center;
}

.inline-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-group input {
    flex: 1;
    min-width: 120px;
}

.delete-btn {
    color: #b13e3e;
    background: transparent !important;
    font-size: 18px !important;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: 0.3s;
}

.delete-btn:hover {
    background: #f8d7da;
}