/* التنسيقات العامة للحاسوب */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    direction: rtl;
}

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

.message.success { background-color: #d4edda; color: #155724; }
.message.error { background-color: #f8d7da; color: #721c24; }
.message.info { background-color: #d1ecf1; color: #0c5460; }

/* الهيدر */
.main-header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    border-radius: 0 0 10px 10px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
}

.header-content h1 {
    color: #2c3e50;
    font-size: 1.8rem;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* الأزرار */
.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #2573a7);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-block;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.btn-logout {
    background: #e74c3c;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-logout:hover {
    background: #c0392b;
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #ecf0f1;
    color: #2c3e50;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-icon:hover {
    background: #bdc3c7;
}

.btn-search {
    background: #3498db;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-size: 14px;
}

.btn-search:hover {
    background: #2980b9;
}

/* صفحة تسجيل الدخول */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 500px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    background: none;
    border: none;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-btn:hover {
    color: #2980b9;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* النماذج */
.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

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

.form-group small {
    margin-top: 5px;
    color: #6c757d;
    font-size: 12px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

/* الإحصائيات السريعة */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease;
}

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

.stat-icon {
    font-size: 2rem;
}

.stat-info h3 {
    color: #2c3e50;
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.stat-info p {
    color: #6c757d;
    margin: 0;
}

/* قسم البحث */
.search-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.search-form {
    display: flex;
    gap: 20px;
    align-items: center;
}

.search-box {
    flex: 1;
    display: flex;
    gap: 10px;
}

.search-box input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #3498db;
}

/* الأقسام العامة */
.records-section,
.profile-sections,
.items-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.records-section h2,
.profile-section h2,
.add-item-section h2,
.items-list-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* شبكة السجلات والعناصر */
.records-grid,
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.record-card,
.item-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border-left: 5px solid #3498db;
    transition: all 0.3s ease;
    position: relative;
}

.record-card:hover,
.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.record-card.linked {
    border-left-color: #27ae60;
}

.record-card.unlinked {
    border-left-color: #e74c3c;
}

.item-card.active {
    border-left-color: #27ae60;
}

.item-card.inactive {
    border-left-color: #95a5a6;
}

.record-header,
.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.record-header h3,
.item-header h3 {
    color: #2c3e50;
    font-size: 1.2rem;
    margin: 0;
    flex: 1;
}

.record-number {
    background: #34495e;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.record-buyer,
.record-merchant,
.item-category,
.item-description,
.item-price {
    margin-bottom: 10px;
    color: #666;
    font-size: 0.9rem;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 8px;
}

.status-badge.linked,
.item-status.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.unlinked,
.item-status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.record-balance {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.record-balance.positive {
    background: #d4edda;
    color: #155724;
}

.record-balance.negative {
    background: #f8d7da;
    color: #721c24;
}

.record-balance.zero {
    background: #e9ecef;
    color: #495057;
}

.balance-label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.balance-amount {
    font-size: 1.3rem;
    font-weight: bold;
}

.record-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 10px 0;
    border-top: 1px solid #e9ecef;
}

.stat {
    text-align: center;
}

.stat small {
    display: block;
    color: #666;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.stat span {
    font-weight: bold;
    color: #2c3e50;
}

.record-actions,
.item-actions {
    text-align: center;
}

.status-toggle {
    text-decoration: none;
    font-size: 1.2rem;
}

.item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
    font-size: 0.8rem;
    color: #666;
}

/* حالة فارغة */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state h3 {
    color: #95a5a6;
    margin-bottom: 10px;
}

.empty-state p {
    margin-bottom: 20px;
}

/* رسائل */
.message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

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

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

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
}

/* صفحة التفاصيل */
.record-overview {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.overview-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.merchant-info h3,
.client-info h3,
.balance-info h4 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.balance-card {
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.balance-card.positive {
    background: #d4edda;
    color: #155724;
}

.balance-card.negative {
    background: #f8d7da;
    color: #721c24;
}

.balance-card.zero {
    background: #e9ecef;
    color: #495057;
}

.balance-amount {
    font-size: 2rem;
    font-weight: bold;
    margin: 10px 0;
}

.balance-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.balance-stats .stat {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

/* العمليات */
.operations-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.operations-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.operation-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-right: 4px solid #3498db;
    transition: all 0.3s ease;
}

.operation-item:hover {
    background: #e9ecef;
}

.operation-item.purchase {
    border-right-color: #e74c3c;
}

.operation-item.payment {
    border-right-color: #27ae60;
}

.operation-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.operation-details {
    flex: 1;
}

.operation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.operation-header h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 1rem;
}

.operation-date {
    color: #666;
    font-size: 0.9rem;
}

.operation-description {
    color: #666;
    margin: 0;
    font-size: 0.9rem;
}

.operation-amount {
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.operation-amount.positive {
    color: #27ae60;
}

.operation-amount.negative {
    color: #e74c3c;
}

/* النوافذ المنبثقة */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    background: #34495e;
    color: white;
    padding: 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #ecf0f1;
}

.modal-form {
    padding: 20px;
}

/* صفحات الربط والإنشاء */
.link-record-section,
.create-record-section {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.link-card h2,
.create-card h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.link-card p,
.create-card p {
    color: #666;
    margin-bottom: 30px;
}

.link-form,
.create-form {
    max-width: 400px;
    margin: 0 auto;
}

/* صفحة العناصر */
.add-item-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.item-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* معلومات الجهاز */
.device-info {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 0.9rem;
}

/* التجاوب */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .search-form {
        flex-direction: column;
        gap: 15px;
    }
    
    .records-grid,
    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .overview-card {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
    }
    
    .auth-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 20px;
    }
    
    .main-header {
        margin-bottom: 15px;
    }
    
    .search-section,
    .records-section,
    .profile-sections {
        padding: 20px;
    }
    
    .operation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* تنسيقات إنشاء المتجر */
.create-store-info {
    background: #e8f4fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-right: 4px solid #3498db;
}

.create-store-info p {
    margin: 0;
    color: #2c3e50;
}

.store-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.store-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border-left: 5px solid #27ae60;
}

.store-status {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.status-icon {
    font-size: 2.5rem;
}

.status-info h3 {
    margin: 0 0 5px 0;
    color: #27ae60;
}

.status-info p {
    margin: 0;
    color: #666;
}

.store-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item strong {
    color: #2c3e50;
}

.info-item span {
    color: #666;
}

/* تنسيقات للهاتف */
@media (max-width: 768px) {
    .store-status {
        flex-direction: column;
        text-align: center;
    }
    
    .store-actions {
        flex-direction: column;
    }
    
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}