
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #2ecc71;
    --secondary-dark: #27ae60;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --warning: #f39c12;
    --warning-dark: #d35400;
    --dark: #2c3e50;
    --dark-light: #34495e;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --gray-light: #bdc3c7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    /*max-width: 1400px;*/
    /*margin: 0 auto;*/
    /*padding: 20px;*/

}

header {
    background: linear-gradient(135deg, var(--primary), var(--dark));
    color: white;
    /*padding: 25px 0;*/
    /*border-radius: 15px;*/
    /*border-radius: 5px;*/
    /*margin-bottom: 25px;*/
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/*header::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
}*/

header h1 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.2rem;
    position: relative;
}

header p {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    opacity: 0.9;
    position: relative;
}

.header-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    position: relative;
}

.header-stat {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
}

nav {
    display: flex;
    justify-content: center;
    background-color: var(--dark);
    border-radius: 10px;
    /*margin-bottom: 25px;*/
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;

}
nav a {
    background: none;
    border: none;
    color: white;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

nav button {
    background: none;
    border: none;
    color: white;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

nav button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

nav button:hover::before {
    left: 100%;
}

nav button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

nav button.active {
    background-color: var(--primary);
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2);
}

.section {
    display: none;
    background-color: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 25px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section.active {
    display: block;
}

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

.section-header h2 {
    color: var(--dark);
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border 0.3s, box-shadow 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

button:active {
    transform: translateY(0);
}

button.danger {
    background-color: var(--danger);
}

button.danger:hover {
    background-color: var(--danger-dark);
}

button.success {
    background-color: var(--secondary);
}

button.success:hover {
    background-color: var(--secondary-dark);
}

button.warning {
    background-color: var(--warning);
}

button.warning:hover {
    background-color: var(--warning-dark);
}

button.outline {
    background-color: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

button.outline:hover {
    background-color: var(--primary);
    color: white;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

th, td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background-color: var(--light);
    font-weight: 700;
    color: var(--dark);
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f9f9f9;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.card {
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    border-top: 4px solid transparent;
}

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

.card h3 {
    margin-bottom: 15px;
    color: var(--dark);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.card .amount {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.card.income {
    border-top-color: var(--secondary);
}

.card.income .amount {
    color: var(--secondary);
}

.card.expenses {
    border-top-color: var(--danger);
}

.card.expenses .amount {
    color: var(--danger);
}

.card.profit {
    border-top-color: var(--primary);
}

.card.profit .amount {
    color: var(--primary);
}

.card.debts {
    border-top-color: var(--warning);
}

.card.debts .amount {
    color: var(--warning);
}

.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    background: var(--light);
    padding: 20px;
    border-radius: 10px;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.search-box {
    position: relative;
    flex: 2;
    min-width: 300px;
}

.search-box input {
    padding-left: 45px;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    background: var(--light);
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

.close-modal {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-modal:hover {
    background-color: var(--light);
    color: var(--dark);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    justify-content: flex-end;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge.success {
    background-color: rgba(46, 204, 113, 0.2);
    color: var(--secondary-dark);
}

.badge.danger {
    background-color: rgba(231, 76, 60, 0.2);
    color: var(--danger-dark);
}

.badge.warning {
    background-color: rgba(243, 156, 18, 0.2);
    color: var(--warning-dark);
}

.badge.info {
    background-color: rgba(52, 152, 219, 0.2);
    color: var(--primary-dark);
}

#toast-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 50px;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, bottom 0.3s;
}

#toast-notification.show {
    opacity: 1;
    visibility: visible;
    bottom: 40px;
}

#toast-notification.success {
    background-color: var(--secondary-dark);
}

#toast-notification.error {
    background-color: var(--danger-dark);
}

.appointment-calendar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.calendar-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.calendar-day-name {
    text-align: center;
    font-weight: bold;
    padding: 10px;
    background: var(--light);
    border-radius: 5px;
}

.calendar-dates {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.calendar-date {
    text-align: center;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.calendar-date:hover {
    background: var(--light);
}

.calendar-date.active {
    background: var(--primary);
    color: white;
}

.calendar-date.has-appointments {
    position: relative;
}

.calendar-date.has-appointments::after {
    content: "";
    position: absolute;
    bottom: 3px;
    right: 50%;
    transform: translateX(50%);
    width: 6px;
    height: 6px;
    background: var(--secondary);
    border-radius: 50%;
}

.appointments-list {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 400px;
    overflow-y: auto;
}

.appointment-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.appointment-time {
    font-weight: bold;
    color: var(--dark);
}

.appointment-patient {
    flex: 1;
    margin: 0 15px;
}

.appointment-status {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
}

.patient-file {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.patient-file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.patient-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.patient-visit {
    background: var(--light);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.visit-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.prescription-item {
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.prescription-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.print-button {
    margin-top: 10px;
}

.whatsapp-button {
    background-color: #25D366;
}

.whatsapp-button:hover {
    background-color: #128C7E;
}

@media (max-width: 768px) {
    nav {
        flex-wrap: wrap;
    }
    .summary-cards { grid-template-columns: 1fr; }
    .filters { flex-direction: column; align-items: stretch;}
    .filter-group, .search-box { min-width: 100%; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .section-actions { width: 100%; justify-content: center; }
    .stats-bar { flex-direction: column; align-items: flex-start; }
    .appointment-calendar { grid-template-columns: 1fr; }

    /* تحسينات للجداول على الهواتف المحمولة */
    .table-container {
        border: 1px solid #e0e0e0;
    }

    table {
        min-width: 100%;
    }

    th, td {
        padding: 12px 8px;
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    /* تحسين عرض الجداول على الهواتف */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    th, td {
        display: inline-block;
        min-width: 120px;
        max-width: none;
        white-space: normal;
        vertical-align: top;
    }

    tr {
        display: block;
        margin-bottom: 10px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 10px;
    }

    thead {
        display: none;
    }

    td::before {
        content: attr(data-label);
        display: block;
        font-weight: bold;
        color: var(--dark);
        margin-bottom: 5px;
        font-size: 12px;
        border-bottom: 1px dashed #e0e0e0;
        padding-bottom: 3px;
    }

    .form-actions {
        flex-direction: column;
        gap: 5px;
    }

    .form-actions button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .section {
        padding: 15px;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .card {
        padding: 15px;
    }

    .card .amount {
        font-size: 24px;
    }

    th, td {
        padding: 10px 6px;
        font-size: 13px;
        min-width: 100px;
    }

    td::before {
        font-size: 11px;
    }
}
