/* ============================================
   DENTAGEST - DENTAL CHART STYLES
   Interactive Odontogram & Treatment Planning
   ============================================ */

/* ============================================
   PAGE LAYOUT
   ============================================ */
.dental-chart-page {
    padding: var(--spacing-lg);
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.dental-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    margin-bottom: var(--spacing-lg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.patient-info {
    display: flex;
    flex-direction: column;
}

.patient-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.patient-phone {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   CHART CONTENT
   ============================================ */
.dental-chart-page .chart-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
    height: auto;
    overflow: visible;
}

.odontogram-container {
    background: transparent;
    padding: 20px 10px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    overflow-x: auto;
    overflow-y: visible;
    min-height: 500px;
    /* Increased to show both arches fully */
}

.treatment-history {
    background: var(--surface-1);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-default);
    min-width: 0;
    max-width: 100%;
}

.treatment-history h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.treatments-table {
    width: 100%;
    border-collapse: collapse;
}

.treatments-table th {
    text-align: left;
    padding: 12px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.treatments-table td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--border-muted);
    color: var(--text-primary);
}

/* Styling for tooth badge */
.tooth-badge {
    display: inline-block;
    background: #eff6ff;
    color: #3b82f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Selected teeth badges in modal */
.selected-teeth-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    min-height: 40px;
}

.tooth-badge-removable {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tooth-badge-removable:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transform: scale(1.05);
}

.tooth-badge-removable .remove-x {
    font-size: 1.1rem;
    font-weight: bold;
    opacity: 0.8;
}

.tooth-badge-removable:hover .remove-x {
    opacity: 1;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.completed {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.planned {
    background: #fef9c3;
    color: #854d0e;
}

/* Modal Styles */
.modal-overlay-hd {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay-hd.active {
    opacity: 1;
    visibility: visible;
}

.modal-hd {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    background: var(--surface-1);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-default);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-hd.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

.modal-hd.treatment-form-modal {
    max-width: 720px;
}

.modal-header-hd {
    padding: 24px;
    border-bottom: 1px solid var(--border-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header-hd h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-body-hd {
    padding: 24px;
    overflow-y: auto;
}

.form-group-hd {
    margin-bottom: 20px;
}

.form-group-hd label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group-hd select,
.form-group-hd input,
.form-group-hd textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border-default);
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: var(--surface-2);
    color: var(--text-primary);
}

.form-group-hd select:focus,
.form-group-hd input:focus {
    outline: none;
    border-color: #3b82f6;
}

.form-row-hd {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.modal-actions-hd {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.btn-primary-hd {
    flex: 1;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary-hd {
    flex: 1;
    padding: 12px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ============================================
   TABS
   ============================================ */
.dental-chart-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-sm);
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
}

.view-toggles {
    display: flex;
    gap: 5px;
    background: var(--surface-2);
    padding: 4px;
    border-radius: 10px;
    margin-left: 20px;
}

.btn-toggle {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--surface-2);
    color: var(--brand-blue);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.tabs-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.toggle-child {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-child input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-blue);
}

/* Header Adjustments for new buttons */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-back .btn-icon {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.header-back .btn-icon:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

/* ============================================
   ÉTAT INITIAL MODAL STYLES
   ============================================ */
.modal-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.initial-state-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.state-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.state-option:hover {
    background: var(--surface-3);
    border-color: var(--border-default);
}

.state-option.selected {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.state-option input {
    display: none;
}

.state-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
}

.state-icon.healthy {
    background: #dcfce7;
    color: #16a34a;
}

.state-icon.treated {
    background: #dbeafe;
    color: #2563eb;
}

.state-icon.decayed {
    background: #fee2e2;
    color: #dc2626;
}

.state-icon.crown {
    background: #fef3c7;
    color: #d97706;
}

.state-icon.missing {
    background: #f1f5f9;
    color: #64748b;
}

.state-label {
    font-weight: 600;
    color: var(--text-primary);
}

.state-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto;
}

/* ============================================
   VIEW-SPECIFIC SECTIONS
   ============================================ */

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h3 {
    margin: 0;
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.plan-total {
    font-size: 1.1rem;
    color: var(--text-primary);
    padding: 8px 16px;
    background: var(--surface-2);
    border-radius: 8px;
}

.plan-total strong {
    color: #22c55e;
}

/* Observations List */
.observations-section {
    background: var(--surface-1);
}

.observations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.observation-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    background: var(--surface-2);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    transition: all 0.2s;
}

.observation-item:hover {
    background: var(--surface-3);
}

.obs-tooth {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.tooth-num {
    font-weight: 600;
    color: var(--text-primary);
}

.obs-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.obs-details {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.obs-notes {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.obs-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.delete-obs {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.observation-item:hover .delete-obs {
    opacity: 1;
}

/* Plan Table */
.treatment-plan-section {
    background: var(--surface-1);
}

.plan-table th:first-child,
.plan-table td:first-child {
    text-align: center;
}

.plan-table code {
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #3b82f6;
}

.plan-payment-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 125px;
}

.plan-payment-summary strong {
    color: var(--text-primary);
}

.plan-payment-summary.has-advance strong {
    color: var(--success);
}

.plan-payment-summary span,
.plan-payment-summary small {
    color: var(--text-muted);
    font-size: 10px;
}

/* Plan Actions Bar */
.plan-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-top: 15px;
    border-top: 1px solid var(--border-default);
}

.plan-actions .btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.plan-actions .btn-secondary:hover {
    background: var(--surface-3);
}

.plan-actions .btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.plan-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Small Action Buttons */
.btn-icon-sm {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-icon-sm:hover {
    opacity: 1;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-style: italic;
}

/* Assign Teeth Button */
.btn-assign-teeth {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0.25) 100%);
    border: 1px dashed var(--brand-gold);
    color: var(--brand-gold);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-assign-teeth:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.25) 0%, rgba(212, 175, 55, 0.35) 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

/* Selected Teeth Preview in Modal */
.selected-teeth-preview {
    min-height: 40px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: 8px;
    border: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
}

.selected-teeth-preview .teeth-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.selected-teeth-preview .tooth-badge.selected {
    background: var(--brand-gold);
    color: var(--dark-bg);
    font-weight: 600;
}

/* Detailed treatment sessions and per-act financial summary */
.treatment-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    border: 1px solid var(--border-muted);
    border-radius: 8px;
}

.treatment-session-table {
    min-width: 1160px;
}

.treatment-session-table th {
    white-space: nowrap;
    letter-spacing: 0;
    text-transform: none;
}

.treatment-session-row.is-primary td {
    background: var(--surface-1);
}

.treatment-session-row.is-follow-up td {
    background: var(--surface-2);
}

.session-date {
    white-space: nowrap;
    font-weight: 600;
}

.session-date.is-pending,
.selection-empty {
    color: var(--text-muted);
    font-weight: 500;
}

.session-treatment-name {
    display: block;
    min-width: 180px;
    line-height: 1.35;
}

.session-count-label {
    display: block;
    margin-top: 4px;
    color: var(--brand-blue);
    font-size: 11px;
    font-weight: 700;
}

.session-notes {
    display: block;
    max-width: 210px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.treatment-session-table .status-badge {
    min-width: 92px;
    border: 0;
    outline: none;
    cursor: pointer;
    text-align: center;
}

.session-payment-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 132px;
}

.session-payment-cell strong {
    color: var(--text-primary);
    font-size: 13px;
}

.session-payment-cell.has-payment strong {
    color: var(--success);
}

.session-payment-cell span {
    color: var(--text-muted);
    font-size: 10px;
}

.treatment-recap-cell {
    min-width: 190px;
    vertical-align: middle;
    background: var(--surface-1) !important;
    border-left: 1px solid var(--border-muted);
    border-right: 1px solid var(--border-muted);
}

.treatment-recap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: var(--surface-2);
}

.recap-label,
.recap-status {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.recap-total {
    color: var(--text-primary);
    font-size: 17px;
}

.recap-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 12px;
}

.recap-progress {
    height: 5px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--border-muted);
}

.recap-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--danger);
}

.treatment-recap.partial .recap-progress span {
    background: var(--warning);
}

.treatment-recap.paid .recap-progress span {
    background: var(--success);
}

.treatment-recap.partial .recap-status {
    color: var(--warning);
}

.treatment-recap.paid .recap-status {
    color: var(--success);
}

.treatment-recap.unpaid .recap-status {
    color: var(--danger);
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 90px;
}

.whole-mouth-badge,
.whole-mouth-selection {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 6px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--brand-blue);
    font-size: 12px;
    font-weight: 700;
}

.whole-mouth-selection {
    width: 100%;
    justify-content: center;
}

.treatment-pricing-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tooth-multi-select {
    min-height: 118px;
    background: var(--surface-1) !important;
}

.tooth-multi-select option {
    padding: 5px 8px;
}

.future-advance-offer {
    margin: 4px 0 20px;
    padding: 14px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.06);
}

.future-advance-toggle {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    margin: 0 !important;
    cursor: pointer;
}

.future-advance-toggle input {
    width: 18px !important;
    margin-top: 2px;
    accent-color: var(--success);
}

.future-advance-toggle span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.future-advance-toggle strong {
    color: var(--text-primary);
}

.future-advance-toggle small {
    color: var(--text-muted);
    font-weight: 400;
}

.future-advance-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(16, 185, 129, 0.25);
}

.future-advance-offer[hidden],
.future-advance-details[hidden] {
    display: none !important;
}

.form-help,
.treatment-scope-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.treatment-scope-hint {
    display: none;
}

.treatment-scope-hint.visible {
    display: block;
    color: var(--brand-blue);
}

@media (max-width: 700px) {
    .treatment-pricing-row {
        grid-template-columns: 1fr;
    }
}
