@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #1f4e78;
    --secondary-color: #2980b9;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --gray-color: #6c757d;
    --border-color: #dee2e6;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.company-logo {
    width: 150px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius);
    font-weight: bold;
    font-size: 18px;
    overflow: hidden;
    /* Removed background color for transparent logo */
}

.company-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    background-color: var(--light-color);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-left: 5px;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
}

.tab i {
    margin-left: 8px;
}

.tab.active {
    background-color: #fff;
    border-bottom: 1px solid #fff;
    color: var(--primary-color);
    font-weight: 600;
    position: relative;
    top: 1px;
}

.tab:hover {
    background-color: #e9ecef;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark-color);
}

input, textarea, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: all 0.3s ease;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.15);
}

/* Use ltr for numeric inputs */
input[type="number"] {
    direction: ltr;
    text-align: right;
}

.btn {
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #19406a;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #218c53;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-info {
    background-color: var(--info-color);
    color: white;
}

.btn-info:hover {
    background-color: #128293;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #e67e22;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-col {
    flex: 1;
}

.card {
    background-color: #fff;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.card-actions {
    display: flex;
    gap: 10px;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background-color: white;
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: #fff;
    margin: 3% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    color: #aaa;
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover,
.close:focus {
    color: var(--primary-color);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background-color: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
}

.badge-info {
    background-color: rgba(23, 162, 184, 0.15);
    color: var(--info-color);
}

/* Print styles */
.print-document {
    width: 21cm;
    min-height: 29.7cm;
    padding: 2cm;
    margin: 1cm auto;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
    font-family: 'Tajawal', sans-serif;
}

.print-header {
    text-align: center;
    margin-bottom: 40px;
}

.print-logo {
    width: 200px;
    height: 90px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 20px;
    overflow: hidden;
    /* Removed background color for transparent logo */
}

.print-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.print-title {
    font-size: 28px;
    font-weight: bold;
    margin: 20px 0;
    color: var(--primary-color);
    text-decoration: underline;
    position: relative;
}

.print-subtitle {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--gray-color);
}

.print-details {
    margin-bottom: 30px;
}

.print-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.print-field {
    margin-bottom: 15px;
}

.print-label {
    font-weight: bold;
    margin-left: 10px;
    color: var(--dark-color);
}

.print-value {
    display: inline-block;
    min-width: 250px;
    border-bottom: 1px solid #ccc;
    padding: 6px 0;
}

.print-amount-box {
    text-align: center;
    margin: 30px 0;
}

.print-amount {
    font-size: 24px;
    font-weight: bold;
    margin: 0 auto;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px 30px;
    display: inline-block;
    background-color: rgba(31, 78, 120, 0.05);
    color: var(--primary-color);
}

/* Modified signatures to improve spacing and appearance */
.print-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 120px;
    padding: 0 40px;
    position: relative;
}

.signature-box {
    text-align: center;
    width: 200px;
    padding: 10px;
    position: relative;
}

.signature-line {
    border-top: 2px solid #000;
    margin-bottom: 10px;
}

.signature-title {
    font-weight: bold;
    font-size: 16px;
    margin-top: 5px;
    color: var(--dark-color);
}

.print-footer {
    position: absolute;
    bottom: 1cm;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    color: var(--gray-color);
    padding: 15px;
    border-top: 1px solid #eee;
}

.document-number {
    position: absolute;
    top: 1cm;
    left: 1cm;
    padding: 5px 15px;
    background-color: rgba(31, 78, 120, 0.1);
    border-radius: 50px;
    font-weight: bold;
    color: var(--primary-color);
}

.document-date {
    position: absolute;
    top: 1cm;
    right: 1cm;
    padding: 5px 15px;
    background-color: rgba(31, 78, 120, 0.1);
    border-radius: 50px;
    font-weight: bold;
    color: var(--primary-color);
}

.watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 150px;
    opacity: 0.03;
    z-index: 0;
    pointer-events: none;
    color: var(--primary-color);
    font-weight: bold;
}

/* Stats Section - Modified to make editable */
.stats-section {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary-color);
    display: flex;
    flex-direction: column;
}

.stat-title {
    font-size: 16px;
    color: var(--gray-color);
    margin-bottom: 10px;
}

.stat-value-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--dark-color);
    flex-grow: 1;
}

.stat-edit {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 16px;
}

.stat-subtitle {
    font-size: 14px;
    color: var(--gray-color);
    margin-top: 5px;
}

.stat-input {
    display: none;
    width: 100%;
    padding: 5px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 18px;
    margin-top: 5px;
}

.balance-adjustment {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.balance-adjustment input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.balance-adjustment button {
    padding: 8px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
}

.receipts-stat {
    border-left-color: var(--success-color);
}

.payments-stat {
    border-left-color: var(--danger-color);
}

.initial-balance-stat {
    border-left-color: var(--primary-color);
}

.balance-stat {
    border-left-color: var(--info-color);
}

.count-stat {
    border-left-color: var(--warning-color);
}

/* Logo upload preview */
.logo-preview {
    width: 150px;
    height: 80px;
    border: 1px dashed var(--border-color);
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Toast notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background-color: var(--success-color);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.5s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background-color: var(--danger-color);
}

/* Print Media Queries - Improved to maintain consistent layout */
@media print {
    @page {
        size: A4;
        margin: 0;
    }
    
    body * {
        visibility: hidden;
    }
    
    .print-container, .print-container * {
        visibility: visible;
    }
    
    .print-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
    }
    
    .print-document {
        box-shadow: none;
        margin: 0;
        padding: 1.5cm;
        border: none;
        width: 100%;
        height: 100%;
        overflow: visible !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    /* Hide document number and date when printing as requested */
    .document-number, .document-date {
        display: none !important;
    }
    
    .modal {
        position: absolute;
        background: none;
        overflow: visible !important;
        height: auto;
    }
    
    .modal-content {
        box-shadow: none;
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: none;
        overflow: visible !important;
    }
    
    /* Ensure signatures print properly */
    .print-signatures {
        page-break-inside: avoid;
        break-inside: avoid;
        display: flex !important;
        justify-content: space-between !important;
        margin-top: 100px !important;
        padding: 0 60px !important;
    }
    
    .signature-box {
        width: 200px !important;
        text-align: center !important;
        padding: 10px !important;
    }
    
    .signature-line {
        border-top: 2px solid #000 !important;
        margin-bottom: 10px !important;
        display: block !important;
    }
    
    .signature-title {
        font-weight: bold !important;
        font-size: 16px !important;
        margin-top: 5px !important;
        display: block !important;
    }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status Indicator */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 5px;
}

.status-receipt {
    background-color: var(--success-color);
}

.status-payment {
    background-color: var(--danger-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--gray-color);
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--dark-color);
}

/* Responsive Design */
@media (max-width: 992px) {
    .stats-section {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
    }
    
    .tab {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .print-signatures {
        flex-direction: column;
        gap: 40px;
    }
    
    .signature-box {
        margin: 0 auto;
    }
}

@media (max-width: 576px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .company-logo {
        margin: 0 auto;
    }
    
    .print-document {
        padding: 1cm;
    }
    
    .document-number, .document-date {
        position: static;
        display: inline-block;
        margin-bottom: 15px;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
    }
}