/**
 * Procdeg - Styles principaux
 * Importation des modules CSS et styles spécifiques à l'application
 */

/* ==================== MODULE IMPORTS ==================== */
/* Note: Les imports sont gérés dans index.html pour compatibilité file:// */

/* ==================== AUTOCOMPLETE ==================== */

/* Container */
.aa-Autocomplete {
    width: 100%;
}

/* Form / Input wrapper - Design compact */
.aa-Form {
    border: 1px solid var(--pico-form-element-border-color, #ccc) !important;
    border-radius: 4px !important;
    background: var(--pico-form-element-background-color, #fff) !important;
    box-shadow: none !important;
    padding: 0 !important;
    height: 36px !important;
    min-height: 36px !important;
}

.aa-Form:focus-within {
    border-color: var(--pico-primary, #1e87f0) !important;
    box-shadow: 0 0 0 2px rgba(30, 135, 240, 0.2) !important;
}

/* Masquer le loading indicator */
.aa-LoadingIndicator {
    display: none !important;
}

/* Bouton submit (icône loupe) */
.aa-SubmitButton {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    cursor: default !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

.aa-SubmitButton:focus,
.aa-SubmitButton:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.aa-SubmitButton svg {
    width: 14px !important;
    height: 14px !important;
    color: #999 !important;
}

/* Icône de recherche - simple et petite */
.aa-InputWrapperPrefix {
    width: 32px !important;
    min-width: 32px !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    padding-left: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
}

.aa-InputWrapperPrefix .aa-Label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    height: 100% !important;
}

/* Input */
.aa-Input {
    font-size: 0.875rem !important;
    padding: 6px 8px !important;
    height: 34px !important;
    background-image: none !important;
    background: transparent !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.aa-Input::-webkit-search-decoration,
.aa-Input::-webkit-search-cancel-button,
.aa-Input::-webkit-search-results-button,
.aa-Input::-webkit-search-results-decoration {
    -webkit-appearance: none !important;
    display: none !important;
}

.aa-Input::placeholder {
    color: #999 !important;
    font-size: 0.875rem !important;
}

/* Suffixe (bouton clear) */
.aa-InputWrapperSuffix {
    width: auto !important;
    padding-right: 6px !important;
}

.aa-ClearButton {
    padding: 4px !important;
    width: 20px !important;
    height: 20px !important;
}

.aa-ClearButton svg {
    width: 12px !important;
    height: 12px !important;
}

/* Panel de résultats */
.aa-Panel {
    z-index: var(--z-dropdown, 100);
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid #ddd !important;
    margin-top: 4px !important;
}

.aa-PanelLayout {
    padding: 0 !important;
    max-height: 320px !important;
}

/* Liste */
.aa-List {
    padding: 0 !important;
    margin: 0 !important;
}

.aa-Item {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

.aa-Item[aria-selected="true"] {
    background: #f0f7ff !important;
}

/* Item custom */
.autocomplete-item {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f5f5f5;
}

.result-item {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.3;
}

.result-item-sub {
    font-size: 0.75rem;
    color: #666;
    margin-top: 1px;
    line-height: 1.3;
}

.result-item-alerte {
    margin-top: 3px;
}

.result-item-alerte .badge {
    font-size: 0.625rem;
    padding: 2px 6px;
}

/* Source header (si présent) */
.aa-SourceHeader {
    display: none !important;
}

/* Footer (si présent) */
.aa-PanelFooter {
    display: none !important;
}

/* ==================== DIALOGS / MODALS ==================== */

dialog {
    border: none;
    border-radius: 6px;
    padding: 0;
    max-width: min(90vw, 700px);
    max-height: 90vh;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    overflow: visible;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog[open] {
    animation: dialog-open 200ms ease-out;
}

@keyframes dialog-open {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.dialog-header h2 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.dialog-body {
    padding: 0.75rem;
    overflow-y: auto;
    max-height: calc(90vh - 100px);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
    border-radius: 0 0 6px 6px;
}

.dialog-footer button {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.dialog-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #999;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1;
}

.dialog-close:hover {
    background: #eee;
    color: #333;
}

/* Info modal (iframe) */
#infoModal .dialog-body {
    padding: 0;
    height: 60vh;
}

#infoModal iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==================== MEDICATION FORM ==================== */

.posology-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.posology-grid label {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
}

.posology-grid input {
    text-align: center;
    padding: 0.375rem;
    font-size: 0.875rem;
}

#posologie_perf {
    display: none;
}

#joursemaine,
#frequence {
    display: none;
}

#joursemaine.visible,
#frequence.visible {
    display: flex;
}

/* ==================== FREQUENCY OPTIONS ==================== */

.frequency-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.frequency-options label {
    font-size: 0.8125rem;
}

.frequency-week {
    display: none;
    flex-wrap: wrap;
    gap: 0.375rem 0.75rem;
}

.frequency-week.visible {
    display: flex;
}

.frequency-week label {
    font-size: 0.8125rem;
}

.frequency-interval {
    display: none;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
}

.frequency-interval.visible {
    display: flex;
}

.frequency-interval input[type="number"] {
    width: 60px;
    padding: 0.375rem;
    font-size: 0.875rem;
}

/* ==================== PRESCRIPTION CATEGORIES ==================== */

.col-prescription,
[data-category="medication"] {
    background-color: var(--color-medication-bg, #ce93d8) !important;
    border-left: 4px solid var(--color-medication, #9c27b0);
}

.col-infirmier,
[data-category="nurse"] {
    background-color: var(--color-nurse-bg, #fff59d) !important;
    border-left: 4px solid var(--color-nurse, #ffc107);
}

.col-reeduc,
[data-category="rehab"] {
    background-color: var(--color-rehab-bg, #a5d6a7) !important;
    border-left: 4px solid var(--color-rehab, #4caf50);
}

/* ==================== SORTABLE (DRAG & DROP) ==================== */

[data-sortable] > * {
    cursor: grab;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

[data-sortable] > *:active {
    cursor: grabbing;
}

[data-sortable] > *.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.sortable-ghost {
    opacity: 0.3;
}

/* ==================== TABLES (IMPRIMER PAGE) ==================== */

.patients-table {
    background: var(--pico-card-background-color);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.patients-table th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #666;
}

.patients-table td,
.patients-table th {
    padding: 0.5rem 0.625rem;
    vertical-align: middle;
    font-size: 0.8125rem;
}

.patient-link {
    color: var(--pico-primary);
    text-decoration: none;
    font-weight: 500;
}

.patient-link:hover {
    text-decoration: underline;
}

.patient-link small {
    font-weight: 400;
    color: #888;
    font-size: 0.75rem;
}

/* ==================== SETTINGS MODAL ==================== */

.settings-section {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.settings-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-section h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.data-info {
    font-size: 0.8125rem;
    color: #666;
    margin-bottom: 0.5rem;
}

/* ==================== KEYBOARD SHORTCUTS HINT ==================== */

kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    color: #333;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
}

/* ==================== UTILITIES ==================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #888; }
.text-small { font-size: 0.8125rem; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.375rem; }
.mb-md { margin-bottom: 0.625rem; }
.mb-lg { margin-bottom: 1rem; }

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-sm {
    gap: var(--spacing-sm);
}

.gap-md {
    gap: var(--spacing-md);
}

/* ==================== HELP PANEL ==================== */

.help-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 250;
}

.help-backdrop.visible {
    display: block;
}

.help-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(380px, 90vw);
    height: 100vh;
    background: var(--pico-card-background-color, #fff);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 250;
    transform: translateX(100%);
    transition: transform 250ms ease;
    display: flex;
    flex-direction: column;
}

.help-panel.open {
    transform: translateX(0);
}

.help-panel.closing {
    transform: translateX(100%);
    transition-duration: 200ms;
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.help-header h2 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.help-nav {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid #e0e0e0;
    background: #f5f5f5;
}

.help-nav-btn {
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #666;
}

.help-nav-btn.active {
    color: var(--pico-primary, #1e87f0);
    border-bottom-color: var(--pico-primary, #1e87f0);
}

.help-nav-btn:hover {
    color: #333;
}

.help-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #444;
}

.help-body h3 {
    font-size: 0.9375rem;
    color: #222;
    margin: 0.75rem 0 0.35rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.2rem;
}

.help-body h3:first-child {
    margin-top: 0;
}

.help-body p {
    margin: 0.35rem 0;
}

.help-body ul {
    padding-left: 1.25rem;
    margin: 0.25rem 0;
}

.help-body li {
    margin: 0.2rem 0;
}

.help-body code {
    background: #f0f0f0;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.8125rem;
}

.help-body a {
    color: var(--pico-primary, #1e87f0);
}

@media (min-width: 769px) {
    .help-backdrop {
        display: none !important;
    }
}
