/* ============================================
   Frånvarovarningar V2 - Feature-specific styles
   ============================================ */

/* Page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--gray-darker, #333);
}

.page-header__subtitle {
    margin: 4px 0 0;
    font-size: 0.875rem;
    color: var(--gray-dark, #666);
}

.page-header__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    background: var(--gray-lightest, #f5f5f5);
    padding: 6px 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.page-header__meta .material-icons {
    font-size: 16px;
    color: var(--gray, #999);
}

/* Info banner */
.info-banner {
    background: var(--cl-super-soft, #e8eaf6);
    border-left: 4px solid var(--cl-hard, #26418f);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--gray-darker, #333);
}

.info-banner .material-icons {
    font-size: 20px;
    color: var(--cl-hard, #26418f);
    flex-shrink: 0;
    margin-top: 1px;
}

.info-banner--warning {
    background: #fff3e0;
    border-left-color: #f57c00;
}

.info-banner--warning .material-icons {
    color: #f57c00;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
}

.filter-bar__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
    margin-right: 4px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid var(--gray-light, #ccc);
    background: var(--white, #fff);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--gray-darker, #333);
    transition: all 0.15s;
    user-select: none;
}

.filter-chip:hover {
    background: var(--gray-lightest, #f5f5f5);
}

.filter-chip--active {
    background: var(--cl-super-soft, #e8eaf6);
    border-color: var(--cl-soft, #7986cb);
    color: var(--cl-hard, #26418f);
    font-weight: 500;
}

.filter-chip__count {
    background: var(--cl-hard, #26418f);
    color: #fff;
    border-radius: 10px;
    font-size: 0.6875rem;
    padding: 1px 7px;
    font-weight: 500;
}

.filter-chip--active .filter-chip__count {
    background: var(--cl-hard, #26418f);
}

.filter-select {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--gray-light, #ccc);
    font-size: 0.8125rem;
    color: var(--gray-darker, #333);
    background: var(--white, #fff);
    cursor: pointer;
}

.filter-bar__spacer {
    flex: 1;
}

/* Alert table */
.alert-table-wrapper {
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    overflow-x: auto;
}

.alert-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.alert-table thead {
    background: var(--gray-lightest, #f5f5f5);
    border-bottom: 2px solid var(--gray-lighter, #e0e0e0);
}

.alert-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 500;
    color: var(--gray-dark, #666);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.alert-table th:hover {
    color: var(--cl-hard, #26418f);
}

.alert-table th .material-icons {
    font-size: 14px;
    vertical-align: middle;
    margin-left: 2px;
}

.alert-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
    vertical-align: top;
}

.alert-table tr:last-child td {
    border-bottom: none;
}

.alert-table tr:hover {
    background: var(--gray-lightest, #fafafa);
}

.alert-table tr.is-new {
    background: #fffde7;
}

.alert-table tr.is-new:hover {
    background: #fff9c4;
}

/* Student cell */
.student-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.student-cell__name {
    font-weight: 500;
    color: var(--cl-hard, #26418f);
    cursor: pointer;
}

.student-cell__name:hover {
    text-decoration: underline;
}

.student-cell__class {
    font-size: 0.75rem;
    color: var(--gray-dark, #666);
}

/* Listing reason */
.listing-reason {
    font-size: 0.8125rem;
    color: var(--gray-darker, #333);
    line-height: 1.4;
}

.listing-reason__primary {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.listing-reason__icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.listing-reason__icon .material-icons {
    font-size: 16px;
    color: #f57c00;
}

.listing-reason__more {
    font-size: 0.75rem;
    color: var(--cl-hard, #26418f);
    cursor: pointer;
    margin-top: 2px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.listing-reason__more:hover {
    text-decoration: underline;
}

/* Value cells */
.value-cell {
    text-align: right;
    white-space: nowrap;
}

.value-cell--highlight {
    font-weight: 500;
    color: #d32f2f;
}

.value-cell--muted {
    color: var(--gray, #999);
}

.value-cell__threshold {
    font-size: 0.6875rem;
    color: var(--gray, #999);
    display: block;
}

/* Data quality indicator */
.data-quality {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #f57c00;
    cursor: help;
}

.data-quality .material-icons {
    font-size: 14px;
}

/* Warning badge */
.warning-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.warning-badge--none {
    background: var(--gray-lightest, #f5f5f5);
    color: var(--gray, #999);
}

.warning-badge--v1 {
    background: #fff3e0;
    color: #e65100;
}

.warning-badge--v2 {
    background: #ffebee;
    color: #c62828;
}

/* New badge */
.new-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: #e3f2fd;
    color: #1565c0;
}

.new-badge .material-icons {
    font-size: 12px;
}

/* Work queue status */
.wq-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
}

.wq--new {
    background: #e3f2fd;
    color: #1565c0;
}

.wq--in-progress {
    background: #fff3e0;
    color: #e65100;
}

.wq--handled {
    background: #e8f5e9;
    color: #2e7d32;
}

.wq--dismissed {
    background: var(--gray-lightest, #f5f5f5);
    color: var(--gray, #999);
}

/* Last warning info */
.last-warning-info {
    font-size: 0.75rem;
    color: var(--gray-dark, #666);
    line-height: 1.3;
}

.last-warning-info__date {
    display: block;
}

.last-warning-info__sender {
    display: block;
    color: var(--gray, #999);
}

/* Action button */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid var(--cl-hard, #26418f);
    background: var(--white, #fff);
    color: var(--cl-hard, #26418f);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--cl-hard, #26418f);
    color: #fff;
}

.action-btn .material-icons {
    font-size: 16px;
}

.action-btn--warning2 {
    border-color: #d32f2f;
    color: #d32f2f;
}

.action-btn--warning2:hover {
    background: #d32f2f;
    color: #fff;
}

.action-btn--small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* Reference column */
.ref-column {
    position: relative;
}

.ref-label {
    display: block;
    font-size: 0.625rem;
    color: var(--gray, #999);
    font-style: italic;
    line-height: 1.2;
    margin-top: 2px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-dark, #666);
}

.empty-state .material-icons {
    font-size: 48px;
    color: var(--gray-light, #ccc);
    margin-bottom: 16px;
}

.empty-state__title {
    font-size: 1.125rem;
    font-weight: 400;
    margin-bottom: 8px;
}

.empty-state__desc {
    font-size: 0.875rem;
}

/* Dialog overlay */
.dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.dialog-overlay.is-open {
    display: flex;
}

.dialog {
    background: var(--white, #fff);
    border-radius: 8px;
    max-width: 640px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
}

.dialog__title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--gray-darker, #333);
    margin: 0;
}

.dialog__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--gray-dark, #666);
    border-radius: 50%;
}

.dialog__close:hover {
    background: var(--gray-lightest, #f5f5f5);
}

.dialog__body {
    padding: 24px;
}

.dialog__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-lighter, #e0e0e0);
}

.dialog__btn {
    padding: 8px 24px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.dialog__btn--secondary {
    background: var(--white, #fff);
    border: 1px solid var(--gray-light, #ccc);
    color: var(--gray-darker, #333);
}

.dialog__btn--secondary:hover {
    background: var(--gray-lightest, #f5f5f5);
}

.dialog__btn--primary {
    background: var(--cl-hard, #26418f);
    border: 1px solid var(--cl-hard, #26418f);
    color: #fff;
}

.dialog__btn--primary:hover {
    background: #1a3070;
}

.dialog__btn--danger {
    background: #d32f2f;
    border: 1px solid #d32f2f;
    color: #fff;
}

.dialog__btn--danger:hover {
    background: #b71c1c;
}

/* Dialog content sections */
.dialog-section {
    margin-bottom: 20px;
}

.dialog-section:last-child {
    margin-bottom: 0;
}

.dialog-section__label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gray-dark, #666);
    margin-bottom: 6px;
}

.dialog-section__value {
    font-size: 0.9375rem;
    color: var(--gray-darker, #333);
}

/* Recipient list in dialog */
.recipient-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recipient-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 0.875rem;
}

.recipient-list__name {
    font-weight: 500;
}

.recipient-list__channels {
    display: flex;
    gap: 6px;
}

.channel-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.channel-badge--ok {
    background: #e8f5e9;
    color: #2e7d32;
}

.channel-badge--missing {
    background: #ffebee;
    color: #c62828;
}

/* History panel */
.history-panel {
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    margin-top: 24px;
}

.history-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
    cursor: pointer;
}

.history-panel__title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-darker, #333);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-panel__body {
    padding: 16px;
}

.history-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-event {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-lighter, #eee);
    font-size: 0.8125rem;
}

.history-event:last-child {
    border-bottom: none;
}

.history-event__icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-event__icon--signal {
    background: #e3f2fd;
    color: #1565c0;
}

.history-event__icon--warning {
    background: #fff3e0;
    color: #e65100;
}

.history-event__icon--escalation {
    background: #fce4ec;
    color: #c62828;
}

.history-event__icon--status {
    background: #e8f5e9;
    color: #2e7d32;
}

.history-event__icon .material-icons {
    font-size: 16px;
}

.history-event__content {
    flex: 1;
}

.history-event__title {
    font-weight: 500;
    color: var(--gray-darker, #333);
    margin-bottom: 2px;
}

.history-event__detail {
    color: var(--gray-dark, #666);
    font-size: 0.75rem;
    line-height: 1.4;
}

.history-event__time {
    font-size: 0.75rem;
    color: var(--gray, #999);
    white-space: nowrap;
}

/* Tabs */
.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--gray-lighter, #e0e0e0);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab-item {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-item:hover {
    color: var(--cl-hard, #26418f);
}

.tab-item--active {
    color: var(--cl-hard, #26418f);
    border-bottom-color: var(--cl-hard, #26418f);
}

.tab-content {
    display: none;
}

.tab-content.is-active {
    display: block;
}

/* Summary cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.summary-card__value {
    font-size: 2rem;
    font-weight: 300;
    color: var(--cl-hard, #26418f);
    line-height: 1;
    margin-bottom: 6px;
}

.summary-card__label {
    font-size: 0.75rem;
    color: var(--gray-dark, #666);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.summary-card--alert .summary-card__value {
    color: #d32f2f;
}

.summary-card--warning .summary-card__value {
    color: #f57c00;
}

.summary-card--success .summary-card__value {
    color: #2e7d32;
}

/* Admin config card */
.config-card {
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.config-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--gray-lightest, #f5f5f5);
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
}

.config-card__title {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.config-card__body {
    padding: 16px;
}

/* Rule row in admin */
.rule-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-lighter, #eee);
    flex-wrap: wrap;
}

.rule-row:last-child {
    border-bottom: none;
}

.rule-row__status {
    width: 32px;
    display: flex;
    justify-content: center;
}

.rule-row__info {
    flex: 1;
    min-width: 200px;
}

.rule-row__name {
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--gray-darker, #333);
}

.rule-row__detail {
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    margin-top: 2px;
}

.rule-row__actions {
    display: flex;
    gap: 8px;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch__slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-light, #ccc);
    border-radius: 24px;
    transition: 0.2s;
}

.toggle-switch__slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .toggle-switch__slider {
    background-color: var(--cl-hard, #26418f);
}

.toggle-switch input:checked + .toggle-switch__slider:before {
    transform: translateX(20px);
}

/* Responsive: Mobile card layout */
@media (max-width: 959px) {
    .alert-table thead {
        display: none;
    }

    .alert-table,
    .alert-table tbody,
    .alert-table tr,
    .alert-table td {
        display: block;
    }

    .alert-table tr {
        margin-bottom: 12px;
        background: var(--white, #fff);
        border: 1px solid var(--gray-lighter, #e0e0e0);
        border-radius: 8px;
        padding: 12px;
    }

    .alert-table td {
        padding: 4px 0;
        border-bottom: none;
        text-align: left !important;
    }

    .alert-table td:before {
        content: attr(data-label);
        font-size: 0.6875rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--gray-dark, #666);
        display: block;
        margin-bottom: 2px;
    }

    .value-cell {
        text-align: left;
    }

    .ref-column,
    .td-ref {
        display: none;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
    }
}

@media (max-width: 599px) {
    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar__label {
        margin-bottom: 4px;
    }

    .filter-chip {
        justify-content: center;
    }
}

/* Notification health (admin) */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.health-item {
    text-align: center;
    padding: 12px;
    background: var(--gray-lightest, #f5f5f5);
    border-radius: 6px;
}

.health-item__value {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--gray-darker, #333);
}

.health-item__label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    color: var(--gray-dark, #666);
    letter-spacing: 0.03em;
    margin-top: 4px;
}

.health-item--ok .health-item__value { color: #2e7d32; }
.health-item--warn .health-item__value { color: #f57c00; }
.health-item--error .health-item__value { color: #d32f2f; }

/* Message preview in dialog */
.message-preview {
    background: var(--gray-lightest, #f5f5f5);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 4px;
    padding: 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* Separator */
.separator {
    height: 1px;
    background: var(--gray-lighter, #e0e0e0);
    margin: 16px 0;
}

/* Admin: Arv indicator */
.arv-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--gray, #999);
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--gray-lightest, #f5f5f5);
}

.arv-indicator .material-icons {
    font-size: 12px;
}
