/* Owned by the milestones package (see ORG-CONFIG-UI-TRACKER.md).
   Case milestones panel, its dialogs and the Timeline & SLA module. Matches the case detail look (app.css). */

.ms-panel {
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
    position: relative;
}

.ms-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.ms-header-sub {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    color: #64748B;
}

.ms-section {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.ms-muted { color: #64748B; font-size: 0.8125rem; margin: 0; }
.ms-nowrap { white-space: nowrap; }
.ms-text-red { color: #B91C1C; font-weight: 500; }

/* ---- Buttons ---- */
.ms-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.4375rem 0.875rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    color: #0F1C35;
    background: #FFFFFF;
    border: 1px solid rgba(15, 28, 53, 0.15);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ms-btn:hover:not(:disabled) { background: #F1F5F9; }
.ms-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ms-btn.primary { color: #FFFFFF; background: #0F766E; border-color: transparent; }
.ms-btn.primary:hover:not(:disabled) { background: #0D5C56; }

.ms-btn.danger { color: #FFFFFF; background: #B91C1C; border-color: transparent; }
.ms-btn.danger:hover:not(:disabled) { background: #991B1B; }

.ms-btn.ghost { color: #475569; font-weight: 500; }

.ms-btn.small { padding: 0.25rem 0.625rem; font-size: 0.6875rem; }

.ms-btn-icon { width: 13px; height: 13px; }

.ms-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.75rem;
    color: #0F766E;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.ms-link:hover { text-decoration: underline; }

.ms-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: msSpin 0.7s linear infinite;
}

@keyframes msSpin { to { transform: rotate(360deg); } }

/* ---- Alerts, empty, skeleton, toast ---- */
.ms-alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid;
}

.ms-alert.info { background: #EFF6FF; border-color: #BFDBFE; color: #1D4ED8; }
.ms-alert.warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.ms-alert.error { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; flex-direction: column; }

.ms-alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.ms-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    text-align: center;
    color: #475569;
    font-size: 0.8125rem;
}

.ms-empty p { margin: 0; }
.ms-empty.small { padding: 1.25rem 1rem; border: 1px dashed rgba(15, 28, 53, 0.12); border-radius: 0.5rem; }

.ms-skeleton { display: flex; flex-direction: column; gap: 0.75rem; }

.ms-skel-line, .ms-skel-block {
    background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
    background-size: 200% 100%;
    animation: msShimmer 1.2s ease-in-out infinite;
    border-radius: 6px;
}

.ms-skel-line { height: 12px; }
.ms-skel-line.w40 { width: 40%; }
.ms-skel-line.w60 { width: 60%; }
.ms-skel-line.w80 { width: 80%; }
.ms-skel-block { height: 120px; }

@keyframes msShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.ms-toast {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1100;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    background: #0F1C35;
    color: #FFFFFF;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 10px 20px rgba(15, 28, 53, 0.18);
    max-width: 420px;
}

/* ---- Badges / tones ---- */
.ms-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    border: 1px solid;
    white-space: nowrap;
    line-height: 1.5;
}

.ms-tone-grey { background: #F1F5F9; color: #475569; border-color: #E2E8F0; }
.ms-tone-blue { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.ms-tone-amber { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.ms-tone-red { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.ms-tone-green { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }

/* ---- Filing limit box ---- */
.ms-filing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid;
}

.ms-filing-main { display: flex; flex-direction: column; gap: 0.125rem; }

.ms-filing-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.ms-filing-text { font-size: 0.8125rem; font-weight: 600; }
.ms-filing-dates { font-size: 0.6875rem; color: #64748B; }

/* ---- Deadlines table ---- */
.ms-table-card {
    background: #FFFFFF;
    border: 1px solid rgba(15, 28, 53, 0.08);
    border-radius: 0.625rem;
    overflow: hidden;
}

.ms-table-scroll { width: 100%; overflow-x: auto; }

.ms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    text-align: left;
}

.ms-table thead tr {
    background: rgba(248, 250, 252, 0.7);
    border-bottom: 1px solid rgba(15, 28, 53, 0.06);
}

.ms-table th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.ms-table td {
    padding: 10px 12px;
    vertical-align: top;
    color: #0F1C35;
    border-top: 1px solid rgba(15, 28, 53, 0.04);
}

.ms-table tr.inactive td { color: #94A3B8; }
.ms-table tr.highlight td { background: #FFFBEB; }

.ms-table tr.ms-dl-extra td {
    border-top: none;
    padding-top: 0;
    font-size: 0.75rem;
    color: #475569;
}

.ms-table tr.ms-dl-extra td span + span { margin-left: 0.5rem; }

.ms-dl-name { font-weight: 500; }
.ms-dl-sub { font-size: 0.6875rem; color: #64748B; margin-top: 3px; }
.ms-dl-sub.moved { color: #0F766E; font-weight: 500; }

.ms-col-actions { width: 1%; }

.ms-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* ---- Events (on top of the case Timeline tab styles) ---- */
.ms-voided-toggle { align-self: flex-end; }

.ms-event { align-items: flex-start; border-radius: 0.5rem; padding: 0.25rem; }
.ms-event.highlight { background: #FFFBEB; outline: 1px solid #FDE68A; }
.ms-event-body { flex: 1; min-width: 0; }

.ms-event-title-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.ms-event.voided .ms-event-title { text-decoration: line-through; color: #94A3B8; }
.ms-event.voided .ms-event-notes,
.ms-event.voided .timeline-date { color: #94A3B8; text-decoration: line-through; }

.ms-marker-grey { background: #CBD5E1; }

.ms-event-notes { white-space: pre-wrap; color: #334155; }
.ms-meta { font-size: 0.6875rem; color: #94A3B8; }
.ms-void-line { color: #64748B; }

.ms-event-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* ---- Dialogs ---- */
.ms-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ms-modal {
    background: #FFFFFF;
    border-radius: 12px;
    max-width: 490px;
    width: 100%;
    max-height: calc(100vh - 2rem);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ms-modal.wide { max-width: 580px; }

.ms-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.125rem 1.25rem 0.875rem;
    border-bottom: 1px solid rgba(15, 28, 53, 0.08);
}

.ms-modal-title { font-size: 1.0625rem; font-weight: 700; color: #0F1C35; margin: 0; }
.ms-modal-subtitle { font-size: 0.75rem; color: #64748B; margin: 0.25rem 0 0; }

.ms-modal-close {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
}

.ms-modal-close:hover:not(:disabled) { background: #F1F5F9; color: #0F1C35; }
.ms-modal-close svg { width: 18px; height: 18px; }

.ms-modal-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    overflow-y: auto;
}

.ms-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.625rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid rgba(15, 28, 53, 0.08);
    background: #F8FAFC;
}

.ms-dialog-text { margin: 0; font-size: 0.8125rem; color: #0F1C35; }

/* ---- Form fields ---- */
.ms-field { display: flex; flex-direction: column; gap: 0.3125rem; }

.ms-label { font-size: 0.75rem; font-weight: 600; color: #334155; }
.ms-req { color: #B91C1C; }

.ms-input, .ms-select, .ms-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-family: inherit;
    color: #0F1C35;
    background: #FFFFFF;
    border: 1px solid rgba(15, 28, 53, 0.15);
    border-radius: 6px;
    outline: none;
}

.ms-input:focus, .ms-select:focus, .ms-textarea:focus {
    border-color: #0F766E;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.ms-input.invalid, .ms-select.invalid, .ms-textarea.invalid { border-color: #DC2626; }
.ms-input:disabled, .ms-select:disabled, .ms-textarea:disabled { background: #F8FAFC; color: #64748B; }
.ms-textarea { resize: vertical; }

.ms-field-foot { display: flex; justify-content: space-between; gap: 0.5rem; }
.ms-error { font-size: 0.6875rem; color: #B91C1C; }
.ms-error:empty { display: none; }
.ms-field-foot .ms-error:empty { display: block; }
.ms-hint { font-size: 0.6875rem; color: #64748B; }
.ms-counter { font-size: 0.6875rem; color: #94A3B8; margin-left: auto; }
.ms-counter.over { color: #B91C1C; font-weight: 600; }

.ms-radio-row { display: flex; gap: 1rem; flex-wrap: wrap; }

.ms-radio, .ms-check {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: #0F1C35;
    cursor: pointer;
}

.ms-check { font-size: 0.75rem; color: #475569; }
.ms-radio.disabled { color: #94A3B8; cursor: not-allowed; }

/* ---- Timeline & SLA module ---- */
.ms-module-intro { display: flex; flex-direction: column; gap: 0.25rem; }
.ms-module-title { margin: 0; font-size: 1rem; font-weight: 700; color: #0F1C35; }
.ms-module-sub { margin: 0; font-size: 0.8125rem; color: #64748B; }

.ms-table-msg { text-align: center; color: #64748B; padding: 1.5rem !important; }

.ms-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(15, 28, 53, 0.06);
    font-size: 0.75rem;
    color: #64748B;
}

.ms-pager-buttons { display: flex; gap: 0.375rem; }

.ms-module-case-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ms-module-case-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: #0F1C35;
}

@media (max-width: 640px) {
    .ms-toast { left: 1rem; right: 1rem; bottom: 1rem; }
    .ms-event { flex-wrap: wrap; }
    .ms-event-actions { flex-direction: row; align-items: center; margin-left: 46px; }
}
