/* ═══════════════════════════════════════
   table.css — All Table Styles
   ═══════════════════════════════════════ */

/* ── Code Cell (prescription code with expand button) ── */
.code-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Table Section Container ── */
.table-section {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin: 0 12px 16px 12px;
}

/* ── Scrollable Table Wrapper ── */
.table-scroll-wrapper {
    overflow: auto;
    max-height: calc(100vh - 300px);
    width: 100%;
}

    .table-scroll-wrapper .mud-table {
        min-width: 100%;
    }

    .table-scroll-wrapper .mud-table-container {
        overflow: auto !important;
        min-height: 80px;
    }

/* ── Search Box in Table Header ── */
.search-wrapper {
    width: 260px;
    margin-right: auto;
}

.search-box-rounded {
    border-radius: 30px !important;
}

    .search-box-rounded .mud-input-slot {
        min-height: 36px !important;
        height: 36px !important;
        border-radius: 30px !important;
    }

    .search-box-rounded input {
        height: 36px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        font-size: 13px !important;
    }

    .search-box-rounded .mud-input-adornment {
        margin-top: 0 !important;
    }

/* ── Responsive height: header sticky, body scrolls independently ──
   Applies to every data page using .patients-table. Dashboard is
   excluded below so its recent-list table keeps its natural height. */
.patients-table .mud-table-container {
    padding: 0;
    max-height: calc(100vh - 300px);
    overflow-y: auto !important;
}

/* Dashboard exception — natural height, no inner scroll */
.dashboard-container .patients-table .mud-table-container {
    max-height: none;
    overflow: visible !important;
}

.patients-table .mud-table-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f8fafc !important;
}

    .patients-table .mud-table-head th,
    .patients-table .mud-table-head .mud-table-cell {
        background: #f8fafc !important;
        color: #1e293b;
        font-weight: 800 !important;
        font-size: 13px;
        padding: 10px 12px !important;
        border-bottom: 2px solid #e2e8f0;
        text-align: right !important;
    }

/* ── Table Rows ── */
.patients-table .mud-table-row {
    height: 40px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    transition: background 0.15s ease;
}

    .patients-table .mud-table-row:hover {
        background: #f8fafc;
    }

/* ── Table Cells ── */
.patients-table .mud-table-cell {
    padding: 5px 12px !important;
    font-size: 13px;
    font-weight: 500 !important;
    border-bottom: 1px solid #f5f5f5 !important;
    text-align: right !important;
    vertical-align: middle;
}

    .patients-table .mud-table-row:last-child .mud-table-cell {
        border-bottom: none !important;
    }

/* ── Pagination ── */
.patients-table .mud-table-pagination {
    border-top: 1px solid #e2e8f0;
    padding: 4px 8px;
    font-size: 13px;
}

/* ── Action Column ── */
.action-column {
    width: 20px;
    min-width: 20px;
    text-align: center !important;
    padding: 0 !important;
}

.patients-table .action-column {
    display: table-cell;
    vertical-align: middle;
}

/* ── Action Buttons ── */
.sound-btn,
.priscription-btn,
.edit-btn,
.delete-btn {
    border-radius: 10px !important;
    width: 30px !important;
    height: 30px !important;
    transition: all 0.2s ease;
    margin: 0 auto !important;
}

    .sound-btn:hover,
    .priscription-btn:hover,
    .edit-btn:hover,
    .delete-btn:hover {
        transform: translateY(-1px);
    }

    .edit-btn .mud-icon-root,
    .delete-btn .mud-icon-root {
        font-size: 18px !important;
    }

.sound-btn {
    background: rgba(34, 197, 94, 0.12) !important;
}

    .sound-btn:hover {
        background: rgba(34, 197, 94, 0.22) !important;
    }

.priscription-btn {
    background: rgba(2, 132, 199, 0.12) !important;
}

    .priscription-btn:hover {
        background: rgba(2, 132, 199, 0.22) !important;
    }

.edit-btn {
    background: rgba(27, 94, 122, 0.12) !important;
}

    .edit-btn:hover {
        background: rgba(27, 94, 122, 0.22) !important;
    }

.delete-btn {
    background: rgba(239, 68, 68, 0.12) !important;
}

    .delete-btn:hover {
        background: rgba(239, 68, 68, 0.22) !important;
    }

/* ── Detail Row (expandable) ── */
.detail-row-container {
    padding: 16px 20px 20px 20px;
    background: #f0f7ff;
    border-top: 1px solid #e2e8f0;
    animation: slideDown 0.3s ease-out;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1a2332;
    font-size: 0.9rem;
}

.detail-count {
    font-size: 0.8rem;
    color: #64748b;
    background: white;
    padding: 2px 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.detail-table-wrapper {
    overflow: auto;
    width: 100%;
}

.drug-detail-table {
    width: 100%;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

    .drug-detail-table .mud-table-container {
        overflow: visible !important;
    }

    .drug-detail-table .mud-table-head {
        background: #f1f5f9 !important;
    }

        .drug-detail-table .mud-table-head th {
            background: #f1f5f9 !important;
            font-weight: 600;
            color: #475569;
            padding: 6px 10px;
            font-size: 0.7rem;
            border-bottom: 1px solid #e2e8f0;
            text-align: right;
        }

    .drug-detail-table .mud-table-body td {
        padding: 6px 10px;
        font-size: 0.8rem;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
    }

        .drug-detail-table .mud-table-body .mud-table-row:hover {
            background: #f8fafc;
        }

        .drug-detail-table .mud-table-body .mud-table-row:last-child td {
            border-bottom: none;
        }

    .drug-detail-table .mud-table-head th:last-child,
    .drug-detail-table .mud-table-body td:last-child {
        text-align: center;
    }

/* ── Responsive ── */
@media (max-width: 768px) {
    .table-section {
        margin: 0 10px 14px 10px;
    }

    .patients-table .mud-table-row {
        height: 38px !important;
    }

    .patients-table .mud-table-cell,
    .patients-table .mud-table-head th,
    .patients-table .mud-table-head .mud-table-cell {
        padding: 4px 8px !important;
        font-size: 12px;
    }

    .table-scroll-wrapper {
        max-height: calc(100vh - 320px);
    }

    .search-wrapper {
        width: 100%;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .drug-detail-table .mud-table-head th,
    .drug-detail-table .mud-table-body td {
        font-size: 0.7rem;
        padding: 4px 6px;
    }
}

@media (max-width: 480px) {
    .table-section {
        margin: 0 8px 12px 8px;
    }

    .patients-table .mud-table-cell,
    .patients-table .mud-table-head th,
    .patients-table .mud-table-head .mud-table-cell {
        padding: 4px 6px !important;
        font-size: 11px;
    }

    .drug-detail-table .mud-table-head th,
    .drug-detail-table .mud-table-body td {
        padding: 3px 4px;
        font-size: 0.55rem;
    }

    .detail-title {
        font-size: 0.75rem;
    }

    .detail-count {
        font-size: 0.65rem;
        padding: 1px 8px;
    }
}
