/* ═══════════════════════════════════════════════════════════════════════════════
   KAIRO - Medical History Styles
   Matches kairo-ui.css and patient-editor.css design system
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── MAIN MODAL ────────────────────────────────────────────────────────────── */

.mh-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50000;
    padding: 20px;
}

.mh-modal {
    background: linear-gradient(135deg, var(--slate-800) 0%, var(--slate-900) 100%);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 20px;
    width: 100%;
    max-width: 950px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 100px rgba(34, 211, 238, 0.1);
    overflow: hidden;
}

.mh-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(90deg, rgba(34, 211, 238, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-bottom: 1px solid rgba(34, 211, 238, 0.2);
}

.mh-modal-header h2 {
    color: var(--cyan-400);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.mh-modal-header h2 span {
    color: var(--gray-200);
    font-weight: 400;
}

.mh-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--gray-400);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mh-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--red-500);
}

/* ─── TABS ──────────────────────────────────────────────────────────────────── */

.mh-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    flex-shrink: 0;
}

.mh-tabs::-webkit-scrollbar {
    height: 4px;
}

.mh-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.mh-tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--gray-400);
    font-size: 13px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mh-tab-btn:hover {
    background: rgba(34, 211, 238, 0.1);
    color: var(--cyan-400);
}

.mh-tab-btn.active {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-color: rgba(34, 211, 238, 0.4);
    color: var(--cyan-400);
}

/* ─── CONTENT AREA ──────────────────────────────────────────────────────────── */

.mh-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.mh-loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
}

.mh-error {
    text-align: center;
    padding: 40px;
    color: var(--red-500);
}

/* ─── SECTIONS ──────────────────────────────────────────────────────────────── */

.mh-section {
    margin-bottom: 24px;
}

.mh-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.mh-section-header h3 {
    color: var(--gray-200);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mh-section-header h4 {
    color: var(--gray-400);
    font-size: 0.875rem;
    font-weight: 500;
    margin: 16px 0 12px 0;
}

.mh-section-header.mh-collapsible {
    cursor: pointer;
    padding: 10px 12px;
    margin: -10px -12px 16px -12px;
    border-radius: 10px;
    transition: background 0.2s;
}

.mh-section-header.mh-collapsible:hover {
    background: rgba(255, 255, 255, 0.03);
}

.mh-collapse-icon {
    color: var(--gray-500);
    font-size: 0.75rem;
    margin-left: auto;
}

.mh-add-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--green-500) 0%, var(--green-600) 100%);
    border: none;
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mh-add-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
}

/* ─── ITEM CARDS ────────────────────────────────────────────────────────────── */

.mh-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mh-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.mh-item-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.2s;
}

.mh-item-card:hover {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(34, 211, 238, 0.3);
}

.mh-item-card.mh-past-item {
    opacity: 0.6;
    background: rgba(15, 23, 42, 0.5);
}

.mh-item-card.mh-compact-card {
    padding: 12px 16px;
}

.mh-item-main {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.mh-item-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.mh-item-info {
    flex: 1;
    min-width: 0;
}

.mh-item-info h4 {
    color: var(--gray-200);
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.mh-item-category {
    color: var(--cyan-400);
    font-size: 0.75rem;
    margin: 0 0 4px 0;
}

.mh-item-details {
    color: var(--gray-400);
    font-size: 0.8125rem;
    margin: 0 0 4px 0;
}

.mh-item-meta {
    color: var(--gray-500);
    font-size: 0.75rem;
    margin: 2px 0;
}

.mh-item-meta.mh-stopped {
    color: var(--amber-400);
}

.mh-item-rating {
    color: #FCD34D;
    font-size: 0.75rem;
    margin: 4px 0 0 0;
}

.mh-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.mh-item-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ─── BUTTONS ───────────────────────────────────────────────────────────────── */

.mh-btn-small {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.mh-btn-edit {
    background: rgba(34, 211, 238, 0.15);
    border-color: rgba(34, 211, 238, 0.3);
    color: var(--cyan-400);
}

.mh-btn-edit:hover {
    background: rgba(34, 211, 238, 0.25);
    border-color: var(--cyan-400);
}

.mh-btn-stop {
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--amber-400);
}

.mh-btn-stop:hover {
    background: rgba(251, 191, 36, 0.25);
    border-color: var(--amber-400);
}

.mh-btn-delete {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--red-500);
}

.mh-btn-delete:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--red-500);
}

.mh-btn-icon {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mh-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mh-btn-icon.mh-btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.mh-btn-icon.mh-btn-stop:hover {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.4);
}

/* ─── SUB MODAL (Add/Edit Forms) ────────────────────────────────────────────── */

.mh-sub-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 51000;
    padding: 20px;
}

.mh-sub-modal-content {
    background: linear-gradient(135deg, var(--slate-800) 0%, var(--slate-900) 100%);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.mh-sub-modal-content.mh-wide-modal {
    max-width: 720px;
}

.mh-sub-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(90deg, rgba(34, 211, 238, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mh-sub-modal-header h3 {
    color: var(--cyan-400);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.mh-sub-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.mh-sub-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─── FORM ELEMENTS ─────────────────────────────────────────────────────────── */

.mh-form-group {
    margin-bottom: 16px;
}

.mh-form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.mh-form-row {
    display: flex;
    gap: 16px;
}

.mh-form-row .mh-form-group {
    flex: 1;
}

.mh-form-row .mh-form-group.mh-flex-2 {
    flex: 2;
}

.mh-input,
.mh-select,
.mh-textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--gray-200);
    font-size: 14px;
    transition: all 0.2s;
}

.mh-input:focus,
.mh-select:focus,
.mh-textarea:focus {
    outline: none;
    border-color: var(--cyan-400);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.mh-input::placeholder {
    color: var(--gray-500);
}

.mh-textarea {
    resize: vertical;
    min-height: 60px;
}

.mh-range {
    width: calc(100% - 40px);
    vertical-align: middle;
    accent-color: var(--cyan-400);
}

.mh-range-value {
    display: inline-block;
    width: 30px;
    text-align: center;
    color: var(--cyan-400);
    font-weight: 600;
}

.mh-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mh-btn-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--gray-400);
}

.mh-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--gray-200);
}

.mh-btn-save {
    background: linear-gradient(135deg, var(--cyan-400) 0%, var(--cyan-500) 100%);
    color: white;
}

.mh-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(34, 211, 238, 0.4);
}

/* ─── AUTOCOMPLETE ──────────────────────────────────────────────────────────── */

.mh-autocomplete-wrapper {
    position: relative;
}

.mh-autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--slate-900);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 10px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    margin-top: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.mh-autocomplete-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
}

.mh-autocomplete-item:hover {
    background: rgba(34, 211, 238, 0.1);
}

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

.mh-autocomplete-item strong {
    color: var(--gray-200);
    display: block;
    margin-bottom: 2px;
}

.mh-autocomplete-secondary {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.mh-autocomplete-item.mh-no-results {
    color: var(--gray-500);
    cursor: default;
}

.mh-autocomplete-item.mh-no-results:hover {
    background: transparent;
}

/* ─── TAGS ──────────────────────────────────────────────────────────────────── */

.mh-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 44px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.mh-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.mh-tag-active {
    background: rgba(34, 211, 238, 0.15);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: var(--cyan-400);
}

.mh-tag-warning {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--amber-400);
}

.mh-tag-severe {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red-500);
}

.mh-tag-genetic {
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: var(--violet-400);
}

.mh-tag-severity,
.mh-tag-status {
    font-size: 0.6875rem;
    opacity: 0.8;
}

.mh-tag-remove {
    background: none;
    border: none;
    color: inherit;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
    transition: opacity 0.2s;
}

.mh-tag-remove:hover {
    opacity: 1;
}

/* ─── CHECKBOX GRID ─────────────────────────────────────────────────────────── */

.mh-conditions-selector,
.mh-allergies-selector,
.mh-genetics-selector {
    margin-top: 20px;
}

.mh-conditions-active h4,
.mh-allergies-active h4,
.mh-genetics-active h4,
.mh-conditions-selector h4,
.mh-allergies-selector h4 {
    color: var(--gray-400);
    font-size: 0.8125rem;
    font-weight: 500;
    margin: 0 0 12px 0;
}

.mh-condition-category,
.mh-allergy-category,
.mh-gene-group {
    margin-bottom: 16px;
}

.mh-condition-category h5,
.mh-allergy-category h5,
.mh-gene-group h5 {
    color: var(--cyan-400);
    font-size: 0.8125rem;
    font-weight: 500;
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(34, 211, 238, 0.2);
}

.mh-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.mh-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.mh-checkbox-item:hover {
    background: rgba(34, 211, 238, 0.1);
    border-color: rgba(34, 211, 238, 0.2);
}

.mh-checkbox-item.mh-checked {
    background: rgba(34, 211, 238, 0.1);
    border-color: rgba(34, 211, 238, 0.4);
}

.mh-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cyan-400);
    cursor: pointer;
}

.mh-checkbox-item span {
    color: var(--gray-300);
    font-size: 0.8125rem;
}

/* ─── LIFESTYLE GRID ────────────────────────────────────────────────────────── */

.mh-lifestyle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.mh-lifestyle-item {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 14px;
}

.mh-lifestyle-item label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.mh-lifestyle-item .mh-input,
.mh-lifestyle-item .mh-select {
    background: rgba(0, 0, 0, 0.3);
}

/* ─── EMPTY STATE ───────────────────────────────────────────────────────────── */

.mh-empty {
    color: var(--gray-500);
    font-size: 0.875rem;
    font-style: italic;
    text-align: center;
    padding: 16px;
}

/* ─── COLLAPSED STATE ───────────────────────────────────────────────────────── */

.mh-collapsed {
    display: none;
}

/* ─── PEPTIDE SPECIFIC ──────────────────────────────────────────────────────── */

.mh-peptide-card .mh-item-info h4 {
    color: var(--violet-400);
}

/* ─── RESPONSIVE ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .mh-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .mh-form-row {
        flex-direction: column;
    }
    
    .mh-tabs {
        padding: 10px 16px;
    }
    
    .mh-tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .mh-checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mh-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .mh-add-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ─── PEPTIDE HORMONE WARNING ────────────────────────────────────────────── */

.mh-hormone-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    margin: 8px 0 16px 0;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 12px;
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.2);
    }
    50% {
        box-shadow: 0 0 20px 4px rgba(245, 158, 11, 0.15);
    }
}

.mh-warning-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
}

.mh-warning-content {
    flex: 1;
}

.mh-warning-content strong {
    display: block;
    color: var(--amber-500);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.mh-warning-content p {
    color: #FCD34D;
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0;
    opacity: 0.9;
}

/* Peptide Hormone Option Styling in Dropdown */
#peptide-select optgroup[label*="Hormone"] {
    background: rgba(245, 158, 11, 0.1);
    font-weight: 600;
}
