/* PERSONAL ALARM HEADER CONTROL */

.settings-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    min-width: 82px;
    min-height: 40px;
    padding: 0 11px;

    border: 1px solid #cfe3d5;
    border-radius: 11px;
    background: #eaf4ed;
    color: #398565;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1px;

    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.settings-trigger::after {
    content: "Alarms";
    white-space: nowrap;
}

.settings-trigger svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.settings-trigger:hover {
    border-color: #a9cdb6;
    background: #e0efe5;
    color: #327858;
    transform: translateY(-1px);
}

.settings-trigger:active {
    transform: translateY(0);
}

.settings-trigger:focus-visible,
.settings-close:focus-visible,
.alarm-enable-button:focus-visible,
.define-button:focus-visible,
.direction-button:focus-visible {
    outline: 3px solid rgba(57, 133, 101, 0.25);
    outline-offset: 3px;
}

.settings-indicator {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 7px;
    height: 7px;
    border: 1.5px solid #eaf4ed;
    border-radius: 50%;
    background: #aab5ae;
    transition: background 0.2s ease;
}

.settings-indicator.has-preferences {
    background: #4aab7b;
}

/* ALARM SETTINGS PANEL */

.alarm-settings-panel {
    display: flex;
    flex-direction: column;

    border: 1px solid #e1eae4;
    border-radius: 17px;
    background: #ffffff;

    box-shadow:
        0 16px 42px rgba(35, 65, 48, 0.12),
        0 3px 9px rgba(35, 65, 48, 0.04);

    opacity: 0;
    transform: translateY(-7px) scale(0.99);
    transform-origin: top right;

    transition:
        opacity 0.18s ease,
        transform 0.2s ease;
}

.alarm-settings-panel[hidden] {
    display: none !important;
}

.alarm-settings-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* PANEL HEADER */

.settings-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 20px 16px;

    border-bottom: 1px solid #edf1ee;
    background: #f8fbf9;
}

.settings-panel-header .eyebrow {
    margin: 0 0 7px;
    color: #82968c;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1.3px;
}

.settings-panel-header h2 {
    margin: 0;
    color: #30483a;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.3px;
}

.settings-subtitle {
    margin: 6px 0 0;
    color: #849189;
    font-size: 11px;
    line-height: 1.5;
}

.settings-close {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 30px;
    height: 30px;

    border: none;
    border-radius: 9px;
    background: transparent;
    color: #87938c;

    font-size: 24px;
    line-height: 1;
    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.settings-close:hover {
    background: #eaf2ec;
    color: #40574a;
}

/* PANEL CONTENT */

.settings-panel-content {
    padding: 17px 20px 13px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* BROWSER SOUND ACTIVATION */

.alarm-activation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 14px;

    border: 1px solid #dfeae3;
    border-radius: 12px;
    background: #f6faf7;
}

.activation-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 5px;
}

.activation-copy strong {
    color: #384d40;
    font-size: 13px;
}

.activation-copy small {
    color: #829087;
    font-size: 11px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.alarm-enable-button {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;

    min-width: 78px;
    min-height: 36px;
    padding: 9px 14px;

    border: 1px solid #398565;
    border-radius: 9px;
    background: #398565;
    color: #ffffff;

    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.alarm-enable-button:hover {
    border-color: #327858;
    background: #327858;
    transform: translateY(-1px);
}

.alarm-enable-button.is-enabled {
    border-color: #70a981;
    background: #70a981;
}

.alarm-enable-button.is-enabled:hover {
    border-color: #5d9470;
    background: #5d9470;
}

/* REPEAT ALARM */

.repeat-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;

    max-height: 0;
    margin-top: 0;
    padding: 0 14px;

    overflow: hidden;
    border: 0 solid #dfeae3;
    border-radius: 12px;
    background: #f9fbf9;

    opacity: 0;
    transform: translateY(-5px);

    transition:
        max-height 0.28s ease,
        margin-top 0.28s ease,
        padding 0.28s ease,
        opacity 0.22s ease,
        transform 0.22s ease,
        border-width 0.28s ease;
}

.repeat-control.is-visible {
    max-height: 110px;
    margin-top: 9px;
    padding: 12px 14px;
    border-width: 1px;
    opacity: 1;
    transform: translateY(0);
}

.repeat-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 4px;
}

.repeat-copy strong {
    color: #414f45;
    font-size: 12px;
}

.repeat-copy small {
    color: #89958d;
    font-size: 10px;
    line-height: 1.5;
}

/* TOGGLE SWITCH */

.switch-control {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    width: 42px;
    height: 24px;
    cursor: pointer;
}

.switch-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 20px;
    background: #d5ddd7;
    transition: background 0.2s ease;
}

.switch-track::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
    content: "";
    transition: transform 0.2s ease;
}

.switch-control input:checked + .switch-track {
    background: #70a981;
}

.switch-control input:checked + .switch-track::after {
    transform: translateX(18px);
}

.switch-control input:focus-visible + .switch-track {
    outline: 3px solid rgba(57, 133, 101, 0.25);
    outline-offset: 3px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* SECTION DIVIDER */

.settings-divider {
    height: 1px;
    margin: 19px 0;
    background: #edf1ee;
}

/* ALERT PREFERENCES HEADING */

.settings-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
}

.settings-section-heading h3 {
    margin: 0;
    color: #384b3e;
    font-size: 13px;
    font-weight: 750;
}

.settings-section-heading span {
    color: #929d95;
    font-size: 10px;
}

/* ALERT CATEGORIES */

.alarm-options {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.alarm-category {
    min-width: 0;
    border-bottom: 1px solid #edf1ee;
}

.alarm-category:last-child {
    border-bottom: none;
}

.alarm-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 13px 3px;
}

/* CATEGORY CHECKBOX */

.category-checkbox {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 11px;
    cursor: pointer;
}

.category-checkbox input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.category-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 4px;
}

.category-copy strong {
    color: #414f45;
    font-size: 12px;
    font-weight: 650;
}

.category-copy small {
    color: #89958d;
    font-size: 10px;
    line-height: 1.4;
}

.custom-checkbox {
    position: relative;
    display: block;
    flex-shrink: 0;
    width: 19px;
    height: 19px;

    border: 1.5px solid #cbd7ce;
    border-radius: 6px;
    background: #ffffff;

    transition:
        background 0.18s ease,
        border-color 0.18s ease;
}

.category-checkbox input:checked + .custom-checkbox {
    border-color: #579776;
    background: #579776;
}

.category-checkbox input:checked + .custom-checkbox::after {
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    content: "";
    transform: rotate(45deg);
}

.category-checkbox input:focus-visible + .custom-checkbox {
    outline: 3px solid rgba(57, 133, 101, 0.22);
    outline-offset: 3px;
}

/* DEFINE BUTTON */

.define-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex-shrink: 0;

    padding: 7px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #628b74;

    font-size: 11px;
    font-weight: 650;
    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.define-button:hover,
.define-button[aria-expanded="true"] {
    background: #edf5ef;
    color: #398565;
}

.define-chevron {
    display: inline-block;
    font-size: 15px;
    line-height: 1;
    transition: transform 0.22s ease;
}

.define-button[aria-expanded="true"] .define-chevron {
    transform: rotate(180deg);
}

/* EXPANDABLE THRESHOLD CONFIGURATION */

.category-config {
    display: grid;
    grid-template-rows: 0fr;
    width: 100%;
    min-width: 0;
    padding-left: 32px;
    opacity: 0;

    transition:
        grid-template-rows 0.28s ease,
        opacity 0.22s ease;
}

.category-config > * {
    min-height: 0;
    overflow: hidden;
}

.category-config.is-expanded {
    grid-template-rows: 1fr;
    opacity: 1;
}

/* THRESHOLD CARD */

.threshold-config {
    width: 100%;
    min-width: 0;
    margin: 0 0 14px;
    padding: 14px;

    border: 1px solid #e5ece7;
    border-radius: 11px;
    background: #f8fbf9;
}

.threshold-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.threshold-heading label {
    min-width: 0;
    color: #596b5f;
    font-size: 11px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.threshold-heading strong {
    min-width: 0;
    color: #398565;
    font-size: 14px;
    font-weight: 750;
    white-space: nowrap;
}

/* SLIDER */

.threshold-slider {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 17px 0 8px;
    accent-color: #579776;
    cursor: pointer;
}

.threshold-slider:focus-visible {
    outline: 2px solid rgba(57, 133, 101, 0.25);
    outline-offset: 4px;
}

.slider-limits {
    display: flex;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    color: #929d95;
    font-size: 9px;
}

/* ALERT DIRECTION */

.direction-heading {
    margin-top: 17px;
    color: #596b5f;
    font-size: 11px;
    font-weight: 600;
}

.direction-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    min-width: 0;
    margin-top: 9px;
}

.direction-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    padding: 9px 7px;

    border: 1px solid #e0e9e3;
    border-radius: 9px;
    background: #ffffff;
    color: #7e8d82;

    font-size: 10px;
    font-weight: 650;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;

    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
}

.direction-button > span {
    font-size: 14px;
}

.direction-button:hover {
    border-color: #c8ddce;
    background: #f5faf6;
    color: #557e65;
}

.direction-button.is-selected {
    border-color: #a9cbb5;
    background: #eaf4ed;
    color: #398565;
}

/* THRESHOLD EXPLANATION */

.threshold-explanation {
    margin: 11px 0 0;
    color: #87958b;
    font-size: 10px;
    line-height: 1.5;
}

/* FEEDBACK */

.alarm-feedback {
    min-height: 15px;
    margin: 8px 0 0;
    color: #628b74;
    font-size: 10px;
    line-height: 1.5;
}

/* PANEL FOOTER */

.settings-panel-footer {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 13px 20px 16px;

    border-top: 1px solid #edf1ee;
    background: #f8fbf9;
}

.settings-footer-icon {
    flex-shrink: 0;
    color: #72917d;
    font-size: 13px;
}

.settings-panel-footer p {
    margin: 0;
    color: #87958b;
    font-size: 10px;
    line-height: 1.55;
}

/* READING WARNING */

.reading-warning {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 16px;
    padding: 13px 15px;

    border: 1px solid #f0d4bd;
    border-radius: 12px;
    background: #fff7f0;
    color: #9b6237;

    font-size: 12px;
    line-height: 1.5;
}

.reading-warning[hidden] {
    display: none;
}

.warning-icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: #fcebdd;
    font-weight: 800;
}

/* POOR CONDITION */

.condition-value.poor,
.response-badge.poor {
    color: #b65353;
}

.response-badge.poor {
    background: #f9e6e6;
}

.verbal-summary.poor {
    border-color: #edcaca;
    border-left-color: #cf6969;
    background: linear-gradient(135deg, #fff5f5, #f9e5e5);
}

.summary-condition.poor {
    color: #b65353;
}

.verbal-summary.poor .summary-status-mark {
    color: #b65353;
}

/* RESPONSIVE ALARM PANEL */

@media (max-width: 650px) {
    .alarm-settings-panel {
        border-radius: 16px;
    }
}

@media (max-width: 480px) {
    .settings-trigger {
        min-width: 76px;
        min-height: 38px;
        padding: 0 9px;
        gap: 6px;
        font-size: 10px;
    }

    .settings-trigger svg {
        width: 17px;
        height: 17px;
    }


    .settings-panel-header {
        padding: 18px 17px 15px;
    }

    .settings-panel-content {
        padding: 15px 17px 11px;
    }

    .settings-panel-footer {
        padding: 12px 17px 14px;
    }

    .alarm-activation {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 9px;
        padding: 12px;
    }

    .alarm-enable-button {
        min-width: 70px;
        padding: 9px 11px;
    }

    .category-config {
        padding-left: 0;
    }

    .threshold-config {
        padding: 12px;
    }

    .direction-options {
        gap: 6px;
    }
}

@media (max-width: 350px) {
    .alarm-activation {
        grid-template-columns: 1fr;
    }

    .alarm-enable-button {
        width: 100%;
    }

    .alarm-option {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px;
    }

    .define-button {
        padding: 7px 5px;
    }

    .direction-options {
        grid-template-columns: 1fr;
    }
}

/* ACCESSIBILITY */

@media (prefers-reduced-motion: reduce) {
    .alarm-settings-panel,
    .settings-trigger,
    .settings-close,
    .alarm-enable-button,
    .custom-checkbox,
    .repeat-control,
    .switch-track,
    .switch-track::after,
    .category-config,
    .define-chevron,
    .direction-button {
        transition: none;
    }
}