/* Medical Share Platform - Public Styles */
/* Color Scheme: Blue (#3B7EA1) with white text */

:root {
    --msp-primary: #3B7EA1;
    --msp-primary-dark: #2E6280;
    --msp-primary-light: #4A90B8;
    --msp-white: #ffffff;
    --msp-light-gray: #f5f5f5;
    --msp-border: #e0e0e0;
    --msp-error: #d32f2f;
    --msp-success: #388e3c;
    --msp-shadow: rgba(0, 0, 0, 0.1);
}

.msp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
}

.msp-dashboard {
    background: var(--msp-white);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--msp-shadow);
    padding: 30px;
    overflow: hidden;
}

.msp-header {
    background: var(--msp-primary);
    color: var(--msp-white);
    padding: 20px;
    border-radius: 8px 8px 0 0;
    margin: -30px -30px 30px;
}

.msp-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--msp-white);
}

.msp-card {
    background: var(--msp-white);
    border: 1px solid var(--msp-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    transition: box-shadow 0.3s;
    overflow: hidden;
}

.msp-card:hover {
    box-shadow: 0 4px 8px var(--msp-shadow);
}

.msp-clickable-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--msp-shadow);
    border-color: var(--msp-primary);
}

.msp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--msp-primary);
}

.msp-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--msp-primary);
    margin: 0;
}

.msp-card-date {
    color: #666;
    font-size: 14px;
}

.msp-button {
    background: var(--msp-primary);
    color: var(--msp-white);
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    text-decoration: none;
    display: inline-block;
}

.msp-button:hover {
    background: var(--msp-primary-dark);
    color: var(--msp-white);
}

.msp-button-secondary {
    background: var(--msp-white);
    color: var(--msp-primary);
    border: 2px solid var(--msp-primary);
}

.msp-button-secondary:hover {
    background: var(--msp-primary);
    color: var(--msp-white);
}

.msp-form-group {
    margin-bottom: 20px;
}

.msp-form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.msp-form-input,
.msp-form-textarea,
.msp-form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--msp-border);
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.msp-form-input:focus,
.msp-form-textarea:focus,
.msp-form-select:focus {
    outline: none;
    border-color: var(--msp-primary);
    box-shadow: 0 0 0 3px rgba(59, 126, 161, 0.1);
}

.msp-form-textarea {
    min-height: 100px;
    resize: vertical;
}

.msp-qr-wrapper {
    text-align: center;
    padding: 30px;
    background: var(--msp-light-gray);
    border-radius: 8px;
    margin: 20px 0;
}

.msp-qr-code {
    max-width: 300px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.msp-qr-url {
    margin-top: 15px;
    font-size: 14px;
    color: #666;
    word-break: break-all;
}

.msp-share-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.msp-share-option {
    border: 2px solid var(--msp-border);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.msp-share-option:hover {
    border-color: var(--msp-primary);
    background: rgba(59, 126, 161, 0.05);
}

.msp-share-option input[type="radio"] {
    margin-right: 10px;
}

.msp-share-option.selected {
    border-color: var(--msp-primary);
    background: rgba(59, 126, 161, 0.1);
}

.msp-error {
    background: #ffebee;
    color: var(--msp-error);
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid var(--msp-error);
}

.msp-success {
    background: #e8f5e9;
    color: var(--msp-success);
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid var(--msp-success);
}

.msp-loading {
    text-align: center;
    padding: 40px;
}

.msp-spinner {
    border: 4px solid var(--msp-light-gray);
    border-top: 4px solid var(--msp-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: msp-spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes msp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.msp-record-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.msp-record-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--msp-border);
}

.msp-record-item:last-child {
    border-bottom: none;
}

/* ===== Custom Checkbox Styling ===== */
.msp-record-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    gap: 15px;
}

.msp-record-item label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    flex: 1;
    padding: 4px 0;
}

.msp-record-checkbox,
.msp-record-item input[type="checkbox"] {
    /* Hide default checkbox */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Custom sizing */
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    /* Custom look */
    border: 2px solid #b0bec5;
    border-radius: 4px;
    background: var(--msp-white);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    margin: 0;
    margin-top: 7px;
    flex-shrink: 0;
}

.msp-record-checkbox:hover,
.msp-record-item input[type="checkbox"]:hover {
    border-color: var(--msp-primary);
    background-color: rgba(59, 126, 161, 0.05);
}

.msp-record-checkbox:focus,
.msp-record-item input[type="checkbox"]:focus {
    outline: none;
    border-color: var(--msp-primary);
    box-shadow: 0 0 0 3px rgba(59, 126, 161, 0.15);
}

.msp-record-checkbox:checked,
.msp-record-item input[type="checkbox"]:checked {
    background-color: var(--msp-primary);
    border-color: var(--msp-primary);
}

.msp-record-checkbox:checked::after,
.msp-record-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid var(--msp-white);
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

/* Card highlight when checkbox is checked */
.msp-card:has(.msp-record-checkbox:checked) {
    border-color: var(--msp-primary);
    background: rgba(59, 126, 161, 0.03);
    box-shadow: 0 0 0 1px var(--msp-primary);
}

/* ===== Custom Radio Button Styling ===== */
.msp-share-option {
    border: 2px solid var(--msp-border);
    border-radius: 8px;
    padding: 18px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.msp-share-option:hover {
    border-color: var(--msp-primary);
    background: rgba(59, 126, 161, 0.04);
}

.msp-share-option input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    border: 2px solid #b0bec5;
    border-radius: 50%;
    background: var(--msp-white);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    margin: 0;
    margin-top: 5px;
    flex-shrink: 0;
}

.msp-share-option input[type="radio"]:hover {
    border-color: var(--msp-primary);
}

.msp-share-option input[type="radio"]:focus {
    outline: none;
    border-color: var(--msp-primary);
    box-shadow: 0 0 0 3px rgba(59, 126, 161, 0.15);
}

.msp-share-option input[type="radio"]:checked {
    border-color: var(--msp-primary);
    border-width: 2px;
}

.msp-share-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--msp-primary);
    border-radius: 50%;
}

/* Active/selected share option card */
.msp-share-option:has(input[type="radio"]:checked) {
    border-color: var(--msp-primary);
    background: rgba(59, 126, 161, 0.06);
    box-shadow: 0 0 0 1px var(--msp-primary);
}

.msp-share-option strong {
    display: block;
    margin-bottom: 2px;
    color: #333;
}

.msp-share-option p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.msp-share-option .msp-share-option-text {
    flex: 1;
}

.msp-prescription-image {
    max-width: 100%;
    width: auto;
    height: auto;
    border-radius: 8px;
    margin-top: 15px;
    box-shadow: 0 2px 4px var(--msp-shadow);
    display: block;
}

/* ===== Filters ===== */
.msp-filters {
    background: var(--msp-light-gray);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.msp-filter-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.msp-filter-field {
    flex: 1;
    min-width: 150px;
}

.msp-filter-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}

.msp-filter-field .msp-form-input,
.msp-filter-field .msp-form-select {
    padding: 8px 10px;
    font-size: 14px;
}

.msp-filter-clear-wrap {
    flex: 0 0 auto;
    min-width: auto;
    padding-bottom: 1px;
}

/* ===== Badges ===== */
.msp-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    vertical-align: middle;
}

.msp-badge-event {
    background: rgba(59, 126, 161, 0.12);
    color: var(--msp-primary-dark);
}

.msp-badge-icd10 {
    background: #f3e5f5;
    color: #6a1b9a;
    font-family: monospace;
    letter-spacing: 0.5px;
}

.msp-badge-ongoing {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ===== Medications Table ===== */
.msp-medications-table-wrap {
    overflow-x: auto;
    margin-top: 10px;
}

.msp-medications-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.msp-medications-table th {
    background: var(--msp-light-gray);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid var(--msp-border);
    white-space: nowrap;
}

.msp-medications-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--msp-border);
    vertical-align: top;
}

.msp-medications-table tbody tr:hover {
    background: rgba(59, 126, 161, 0.03);
}

/* Inline medication display on record cards */
.msp-medications-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.msp-med-inline-item {
    background: var(--msp-light-gray);
    border: 1px solid var(--msp-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.msp-med-inline-name {
    font-weight: 600;
    color: #333;
}

.msp-med-inline-detail {
    color: #666;
}

.msp-med-inline-detail::before {
    content: '·';
    margin-right: 2px;
}

/* ===== Medication Form Rows ===== */
.msp-medication-row {
    background: var(--msp-light-gray);
    border: 1px solid var(--msp-border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

/* ===== Medication Autocomplete ===== */
.msp-autocomplete-dropdown {
    background: var(--msp-white);
    border: 1px solid var(--msp-border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 220px;
    overflow-y: auto;
    left: 0;
    right: 0;
    top: 100%;
    -webkit-overflow-scrolling: touch;
}

.msp-autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background 0.1s;
}

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

.msp-autocomplete-item:hover,
.msp-autocomplete-item.msp-autocomplete-active {
    background: rgba(59, 126, 161, 0.1);
    color: var(--msp-primary-dark);
}

.msp-autocomplete-item strong {
    color: var(--msp-primary);
    font-weight: 700;
}

.msp-med-name {
    position: relative;
}

.msp-med-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    align-items: start;
}

.msp-med-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}

.msp-med-field .msp-form-input {
    padding: 8px 10px;
    font-size: 14px;
}

.msp-med-ongoing-label {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding-top: 20px;
    font-size: 14px !important;
    cursor: pointer;
}

.msp-med-remove {
    display: flex;
    align-items: flex-start;
    padding-top: 18px;
}

.msp-med-remove-btn {
    background: var(--msp-error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 18px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}

.msp-med-remove-btn:hover {
    background: #b71c1c;
}

/* Section spacing */
.msp-section {
    margin-bottom: 10px;
}

/* ===== Medication Share Block (in Share Records) ===== */
.msp-meds-share-block {
    border: 2px solid var(--msp-primary);
    border-left: 5px solid var(--msp-primary);
    background: rgba(59, 126, 161, 0.02);
    margin-bottom: 20px;
}

.msp-meds-share-block:has(.msp-med-checkbox:checked),
.msp-meds-share-block:has(.msp-select-all-meds-cb:checked) {
    background: rgba(59, 126, 161, 0.06);
    box-shadow: 0 0 0 1px var(--msp-primary);
}

.msp-meds-share-header {
    margin-bottom: 10px;
}

.msp-meds-share-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.msp-meds-share-title-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    font-size: 16px;
}

.msp-meds-toggle-btn {
    background: none;
    border: 1px solid var(--msp-border);
    border-radius: 4px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.msp-meds-toggle-btn:hover {
    border-color: var(--msp-primary);
    color: var(--msp-primary);
    background: rgba(59, 126, 161, 0.05);
}

.msp-meds-share-hint {
    font-size: 13px;
    color: #888;
    margin: 6px 0 0 36px;
}

.msp-meds-detail-list {
    border-top: 1px solid var(--msp-border);
    margin-top: 12px;
    padding-top: 8px;
}

.msp-med-share-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: background 0.15s;
}

.msp-med-share-row:last-child {
    border-bottom: none;
}

.msp-med-share-row:hover {
    background: rgba(59, 126, 161, 0.04);
}

.msp-med-share-row .msp-record-checkbox {
    margin-top: 3px;
}

.msp-med-share-label {
    cursor: pointer;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msp-med-share-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.msp-med-share-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 13px;
    color: #666;
}

.msp-med-share-details span:not(.msp-badge)::before {
    content: '';
}

.msp-med-share-details > span + span:not(.msp-badge):not(.msp-med-share-prac)::before {
    content: '·';
    margin-right: 2px;
}

.msp-med-share-prac {
    color: #888;
    font-style: italic;
}

/* ===== Auth Gate (Login/Register Prompt) ===== */
.msp-auth-gate {
    text-align: center;
    padding: 50px 20px;
}

.msp-auth-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.msp-auth-title {
    font-size: 24px;
    color: #333;
    margin: 0 0 10px;
}

.msp-auth-text {
    color: #666;
    font-size: 16px;
    margin: 0 0 30px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.msp-auth-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.msp-auth-actions .msp-button {
    min-width: 160px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

/* ===== Share URL Box & Action Buttons ===== */
.msp-share-url-box {
    margin: 20px 0 15px;
}

.msp-share-url-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.msp-share-url-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.msp-share-url-input {
    flex: 1;
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--msp-border);
    border-radius: 4px;
    background: var(--msp-light-gray);
    color: #333;
    font-family: monospace;
}

.msp-copy-btn {
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
}

.msp-share-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.msp-share-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    flex: 1;
    justify-content: center;
    min-width: 140px;
}

.msp-share-whatsapp {
    background: #25D366;
    color: #fff;
}

.msp-share-whatsapp:hover {
    background: #1DA851;
    color: #fff;
}

.msp-share-email {
    background: var(--msp-primary);
    color: #fff;
}

.msp-share-email:hover {
    background: var(--msp-primary-dark);
    color: #fff;
}
