/* Modern Medical Table Styling */

.medical-table-wrapper {
    background: #f8fafc;
    padding: 2rem;
    border-radius: var(--border-radius);
    border: 1px solid #e2e8f0;
    margin: 1.5rem 0;
}

.medical-table-container {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid #e2e8f0;
}

.table-header-section {
    background: var(--sidebar-gradient);
    color: white;
    padding: 2rem;
    text-align: center;
}

.table-main-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.table-subtitle {
    font-size: 0.8rem;
    opacity: 0.8;
}

.medical-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8rem;
}

.medical-table th {
    background: #f1f5f9;
    color: #475569;
    padding: 1rem;
    font-weight: 700;
    border-bottom: 2px solid #e2e8f0;
    border-inline-end: 1px solid #e2e8f0;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.medical-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    border-inline-end: 1px solid #f1f5f9;
    transition: var(--transition);
}

.medical-table tbody tr:hover td {
    background-color: #f8fafc;
}

/* Specialized Cell Styles */
.patient-info {
    background-color: #f8fafc !important;
    font-weight: 600;
    color: var(--primary-color);
}

.medication-info {
    color: var(--success-color);
    font-weight: 500;
}

.input-cell {
    padding: 0 !important;
}

.input-cell input {
    width: 100%;
    height: 100%;
    border: none;
    padding: 0.875rem 1rem;
    text-align: center;
    background: transparent;
    font-weight: 600;
    color: var(--text-main);
}

.input-cell input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    background: white;
}

/* أزرار العمل */
.action-buttons {
    margin: 25px 0;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
}

.btn-medical {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    margin: 8px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.4s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-medical::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.btn-medical:hover::before {
    left: 100%;
}

.btn-medical:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.4);
    color: white;
}

.btn-medical.btn-success {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-medical.btn-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

.btn-medical.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

/* تأثيرات الأنيميشن */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.medical-table tbody tr {
    animation: fadeInUp 0.6s ease forwards;
}

.medical-table tbody tr:nth-child(1) { animation-delay: 0.1s; }
.medical-table tbody tr:nth-child(2) { animation-delay: 0.2s; }
.medical-table tbody tr:nth-child(3) { animation-delay: 0.3s; }
.medical-table tbody tr:nth-child(4) { animation-delay: 0.4s; }
.medical-table tbody tr:nth-child(5) { animation-delay: 0.5s; }

/* تصميم الطباعة */
@media print {
    .no-print { 
        display: none !important; 
    }
    
    .medical-table-wrapper {
        background: white !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    
    .medical-table {
        font-size: 10px;
        page-break-inside: avoid;
    }
    
    .medical-table th,
    .medical-table td {
        padding: 6px 4px;
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
    }
    
    .medical-table th {
        background: #f0f0f0 !important;
        color: black !important;
    }
}

/* التصميم المتجاوب */
@media (max-width: 1200px) {
    .medical-table-wrapper {
        padding: 15px;
    }
    
    .medical-table {
        font-size: 11px;
    }
    
    .medical-table th,
    .medical-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 768px) {
    .medical-table-wrapper {
        overflow-x: auto;
        padding: 10px;
    }
    
    .medical-table {
        min-width: 1200px;
        font-size: 10px;
    }
    
    .medical-table th,
    .medical-table td {
        padding: 6px 4px;
    }
    
    .action-buttons {
        padding: 15px;
    }
    
    .btn-medical {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}

/* تصميم الخلايا القابلة للتحرير - مثل Excel */
.editable-cell, .number-cell, .date-cell {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.editable-cell:hover, .number-cell:hover, .date-cell:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border: 2px solid #2196f3 !important;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.3);
}

.editable-cell.editing, .number-cell.editing, .date-cell.editing {
    padding: 0 !important;
    background: white !important;
    border: 2px solid #4caf50 !important;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

.cell-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 13px;
    font-weight: inherit;
    color: inherit;
    padding: 10px 8px;
    outline: none;
    font-family: inherit;
}

.cell-input:focus {
    background: white;
    border-radius: 4px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

/* مؤشر التحرير */
.editable-cell::after, .number-cell::after, .date-cell::after {
    content: '✎';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    color: #666;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.editable-cell:hover::after, .number-cell:hover::after, .date-cell:hover::after {
    opacity: 1;
}

.editable-cell.editing::after, .number-cell.editing::after, .date-cell.editing::after {
    content: '✓';
    color: #4caf50;
    opacity: 1;
}

/* تحسين تصميم الجدول للتفاعل */
.medical-table td {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.medical-table td.editing {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* تأثيرات الصف النشط */
.medical-table tbody tr.active-row {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%) !important;
    border-left: 4px solid #ff9800;
    transform: scale(1.01);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.2);
}

/* تحسين شكل الخلايا الرقمية */
.number-cell {
    font-weight: bold;
    color: #1976d2;
}

.number-cell:hover {
    color: #0d47a1;
}

/* تحسين خلايا التاريخ */
.date-cell {
    font-weight: 600;
    color: #d32f2f;
}

/* رسائل المساعدة */
.cell-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.cell-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0,0,0,0.8);
}

.editable-cell:hover .cell-tooltip,
.number-cell:hover .cell-tooltip,
.date-cell:hover .cell-tooltip {
    opacity: 1;
}

/* تحسين الاستجابة للوحة المفاتيح */
.medical-table tbody tr.selected {
    outline: 2px solid #2196f3;
    outline-offset: -2px;
}

.medical-table tbody tr.selected td {
    background: rgba(33, 150, 243, 0.1) !important;
}

.table-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1f4e79 100%);
}

/* تأثيرات التفاعل */
.input-cell input[type="number"]::-webkit-outer-spin-button,
.input-cell input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-cell input[type="number"] {
    -moz-appearance: textfield;
}

.medical-table td.highlight {
    background: linear-gradient(135deg, #fff9c4 0%, #f7dc6f 100%) !important;
    border: 2px solid #f1c40f !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}