/**
 * Agendas & Minutes Manager Styles
 * @package AMM
 * @since 2.0.0
 * 
 * ADA/WCAG 2.1 AA Compliant
 */

/* === CSS Custom Properties (defaults, overridden by PHP) === */
:root {
    --amm-primary: #2563eb; /* WCAG AA contrast compliant */
    --amm-primary-dark: #1d4ed8;
    --amm-accent: #059669; /* WCAG AA contrast compliant */
    --amm-accent-dark: #047857;
    --amm-danger: #dc2626; /* WCAG AA contrast compliant */
    --amm-danger-dark: #b91c1c;
    --amm-text: #1f2937;
    --amm-muted: #4b5563; /* Darkened for better contrast */
    --amm-bg: #ffffff;
    --amm-border: #d1d5db;
    --amm-radius: 0.5rem;
    --amm-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --amm-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --amm-focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

/* === Accessibility Utilities === */
.amm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.amm-sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Skip link for keyboard navigation */
.amm-skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: var(--amm-primary);
    color: #fff;
    padding: 0.5rem 1rem;
    z-index: 100001;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    font-weight: 600;
    white-space: nowrap;
}

.amm-skip-link:focus,
.amm-skip-link:focus-visible {
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
    outline: 2px solid #fff;
    outline-offset: -4px;
}

/* ============================================
   SVG ICONS (WCAG-compliant emoji replacement)
   Uses currentColor so icons respect text color,
   hover states, focus rings, and high-contrast mode.
   ============================================ */
.amm-svg-icon {
    display: inline-block;
    vertical-align: -0.15em;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    pointer-events: none;
}

.amm-btn .amm-svg-icon,
.amm-nav-links .amm-svg-icon {
    width: 1.05em;
    height: 1.05em;
    margin-right: 0.35em;
}

.amm-empty-icon.amm-svg-icon,
.amm-empty-message .amm-svg-icon {
    width: 3em;
    height: 3em;
    opacity: 0.4;
}

/* Windows High Contrast Mode — ensure visibility */
@media (forced-colors: active) {
    .amm-svg-icon {
        stroke: CanvasText;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --amm-border: #000;
        --amm-muted: #000;
    }
    
    .amm-btn {
        border-width: 2px;
    }
}

/* Focus visible for keyboard navigation */
.amm-wrap *:focus,
.amm-container *:focus {
    outline: none;
}

.amm-wrap *:focus-visible,
.amm-container *:focus-visible {
    outline: 2px solid var(--amm-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Extra-prominent focus for critical interactive elements */
.amm-doc-link:focus-visible,
.amm-skip-link:focus-visible,
.amm-btn:focus-visible {
    outline: 3px solid var(--amm-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.25);
}

/* === Base Container === */
.amm-container {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--amm-text);
    background: var(--amm-bg);
    max-width: 100%;
}

.amm-container *,
.amm-container *::before,
.amm-container *::after {
    box-sizing: border-box;
}

/* === Typography === */
.amm-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--amm-text);
}

.amm-subtitle {
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    color: var(--amm-muted);
}

.amm-header {
    margin-bottom: 2rem;
}

.amm-text-muted {
    color: var(--amm-muted);
    font-size: 0.9375rem;
    margin: 0 0 1rem;
}

.amm-muted {
    color: var(--amm-muted);
    font-size: 0.875rem;
}

/* === Navigation Bar === */
.amm-nav,
.amm-navbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--amm-bg);
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    margin-bottom: 1.5rem;
}

.amm-nav-user,
.amm-navbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--amm-muted);
    font-size: 0.875rem;
}

.amm-nav-links,
.amm-navbar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-left: auto;
}

.amm-nav a,
.amm-navbar a {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    color: var(--amm-text);
    text-decoration: none;
    border-radius: var(--amm-radius);
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.amm-nav a:hover,
.amm-navbar a:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--amm-primary);
}

.amm-nav a.active,
.amm-navbar a.active {
    background: var(--amm-primary);
    color: #fff;
}

.amm-navbar-spacer {
    flex: 1;
}

/* === Grid System === */
.amm-grid {
    display: grid;
    gap: 1.5rem;
}

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

.amm-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.amm-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 992px) {
    .amm-grid-3,
    .amm-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .amm-grid-2,
    .amm-grid-3,
    .amm-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* === Category Form Layout === */
.amm-category-form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.amm-category-form-row .amm-field-grow {
    flex: 2;
    min-width: 200px;
}

.amm-category-form-row .amm-field:not(.amm-field-grow):not(.amm-field-btn) {
    flex: 1;
    min-width: 150px;
}

.amm-category-form-row .amm-field-btn {
    flex-shrink: 0;
}

.amm-optional {
    font-weight: 400;
    font-size: 0.8125rem;
    color: var(--amm-muted);
}

.amm-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    background: var(--amm-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    margin-left: 0.5rem;
}

.amm-empty-message {
    text-align: center;
    padding: 2rem;
    color: var(--amm-muted);
}

.amm-empty-message .amm-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.amm-empty-message p {
    margin: 0;
}

@media (max-width: 640px) {
    .amm-category-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .amm-category-form-row .amm-field-grow,
    .amm-category-form-row .amm-field {
        flex: none;
        width: 100%;
    }
}

/* === Form Elements === */
.amm-form-group {
    margin-bottom: 1rem;
}

.amm-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .amm-form-grid {
        grid-template-columns: 1fr;
    }
}

.amm-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
    color: var(--amm-text);
}

.amm-input,
.amm-select,
.amm-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--amm-text);
    background: var(--amm-bg);
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.amm-input:focus,
.amm-select:focus,
.amm-textarea:focus {
    outline: none;
    border-color: var(--amm-primary);
    box-shadow: var(--amm-focus-ring);
}

/* Focus visible for file input labels */
.amm-file-input:focus-visible + label {
    outline: 2px solid var(--amm-primary);
    outline-offset: 2px;
}

/* Error states */
.amm-input[aria-invalid="true"],
.amm-select[aria-invalid="true"],
.amm-textarea[aria-invalid="true"] {
    border-color: var(--amm-danger);
}

.amm-input[aria-invalid="true"]:focus,
.amm-select[aria-invalid="true"]:focus,
.amm-textarea[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
}

.amm-error-message {
    color: var(--amm-danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.amm-input::placeholder {
    color: var(--amm-muted);
}

.amm-input[type="file"] {
    padding: 0.5rem;
}

/* File input hidden - use label as button */
.amm-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.amm-file-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.amm-file-name {
    font-size: 0.875rem;
    color: var(--amm-muted);
}

.amm-or {
    text-align: center;
    color: var(--amm-muted);
    font-size: 0.8125rem;
    margin: 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.amm-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--amm-muted);
}

/* === Buttons === */
.amm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--amm-text);
    background: var(--amm-bg);
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.amm-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: var(--amm-text);
    text-decoration: none;
}

.amm-btn:focus {
    outline: none;
    box-shadow: var(--amm-focus-ring);
}

.amm-btn:focus-visible {
    outline: 2px solid var(--amm-primary);
    outline-offset: 2px;
    box-shadow: none;
}

.amm-btn:disabled,
.amm-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.amm-btn-primary {
    background: var(--amm-primary);
    border-color: var(--amm-primary);
    color: #fff;
}

.amm-btn-primary:hover {
    background: var(--amm-primary-dark);
    border-color: var(--amm-primary-dark);
    color: #fff;
}

.amm-btn-primary:focus-visible {
    outline-color: var(--amm-primary-dark);
}

.amm-btn-accent {
    background: var(--amm-accent);
    border-color: var(--amm-accent);
    color: #fff;
}

.amm-btn-accent:hover {
    background: var(--amm-accent-dark);
    border-color: var(--amm-accent-dark);
    color: #fff;
}

.amm-btn-accent:focus-visible {
    outline-color: var(--amm-accent-dark);
}

.amm-btn-danger {
    background: var(--amm-danger);
    border-color: var(--amm-danger);
    color: #fff;
}

.amm-btn-danger:hover {
    background: var(--amm-danger-dark);
    border-color: var(--amm-danger-dark);
    color: #fff;
}

.amm-btn-danger:focus-visible {
    outline-color: var(--amm-danger-dark);
}

.amm-btn-outline {
    background: transparent;
    border-color: var(--amm-border);
    color: var(--amm-text);
}

.amm-btn-outline:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: var(--amm-text);
}

.amm-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.amm-btn-icon {
    padding: 0.5rem;
    min-width: 2.25rem;
}

/* === Button Groups === */
.amm-btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* === Grid Layout === */
.amm-grid {
    display: grid;
    gap: 1rem;
}

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

.amm-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.amm-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
    .amm-grid-2,
    .amm-grid-3,
    .amm-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* === Filter Controls === */
.amm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    margin-bottom: 1rem;
}

.amm-filters .amm-form-group {
    margin: 0;
    min-width: 150px;
    flex: 1;
}

.amm-filters .amm-btn-group {
    align-items: flex-end;
}

/* === Filters Grid (new layout) === */
.amm-filters-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

.amm-filters-grid .amm-field {
    margin: 0;
}

@media (max-width: 992px) {
    .amm-filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .amm-filters-grid {
        grid-template-columns: 1fr;
    }
}

/* === Table === */
.amm-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
}

.amm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.amm-table th,
.amm-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--amm-border);
}

.amm-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--amm-muted);
    white-space: nowrap;
}

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

.amm-table tbody tr:hover {
    background: #f9fafb;
}

/* Sortable columns */
.amm-sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem !important;
}

.amm-sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    opacity: 0.4;
}

.amm-sortable.sort-asc::after {
    content: '↑';
    opacity: 0.8;
}

.amm-sortable.sort-desc::after {
    content: '↓';
    opacity: 0.8;
}

/* Category table styles */
.amm-slug-code {
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8125rem;
    color: var(--amm-muted);
}

.amm-meeting-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.75rem;
    background: #e5e7eb;
    color: var(--amm-text);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 9999px;
}

.amm-actions-cell {
    white-space: nowrap;
}

.amm-actions-cell .amm-btn {
    margin-right: 0.5rem;
}

.amm-actions-cell .amm-btn:last-child {
    margin-right: 0;
}

/* Table links — WCAG AA/AAA compliant contrast
   Text #1e3a8a (blue-900) on solid #dbeafe (blue-100) = ~10.4:1 contrast (AAA)
   Hover: white on #1d4ed8 (blue-700) = ~8.6:1 contrast (AAA) */
.amm-doc-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e3a8a !important;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    border: 1px solid #93c5fd;
    border-radius: 0.25rem;
    background: #dbeafe !important;
    transition: all 0.2s ease;
}

/* === LVHA ORDER MATTERS ===
   :link → :visited → :hover/:focus → :active
   Breaking this order lets :visited override :hover color (same specificity,
   later source order wins). That was the v2.7.7/2.7.8 bug. */

.amm-doc-link:visited {
    color: #1e3a8a !important;
    background: #dbeafe !important;
}

.amm-doc-link:hover,
.amm-doc-link:focus,
.amm-doc-link:visited:hover,
.amm-doc-link:visited:focus {
    background: #1d4ed8 !important;
    color: #ffffff !important;
    border-color: #1d4ed8 !important;
    text-decoration: underline;
    outline: 2px solid #1e3a8a;
    outline-offset: 2px;
}

/* Force descendants (spans, svg) to inherit the anchor's color so the icon
   and any wrapped text recolor with the pill on hover. Scope to children
   ONLY — applying to .amm-doc-link itself would inherit from the <td> and
   override the :hover color. */
.amm-doc-link > *,
.amm-doc-link span,
.amm-doc-link svg {
    color: inherit !important;
}
.amm-doc-link .amm-doc-icon {
    stroke: currentColor;
    fill: none;
    vertical-align: -2px;
    margin-right: 4px;
    flex-shrink: 0;
}
.amm-doc-link:hover .amm-doc-icon,
.amm-doc-link:focus .amm-doc-icon,
.amm-doc-link:visited:hover .amm-doc-icon,
.amm-doc-link:visited:focus .amm-doc-icon {
    stroke: #ffffff !important;
    color: #ffffff !important;
}

/* :visited handled above in LVHA block — do not re-declare here or it
   overrides :hover color again (same specificity, later source wins). */

.amm-doc-missing {
    color: #374151 !important;
    background: #f3f4f6 !important;
    border: 1px solid #d1d5db;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-style: italic;
    font-size: 0.875rem;
}

/* Ensure table cell text meets AA contrast on all backgrounds */
.amm-container table td,
.amm-container table th,
.amm-container[data-amm-component="public-table"] td,
.amm-container[data-amm-component="public-table"] th {
    color: #1f2937 !important;
}

/* Document icon (emoji) — ensure adjacent label text has strong contrast */
.amm-doc-link::before,
.amm-doc-cell {
    color: inherit;
}

/* === Pagination === */
.amm-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    flex-wrap: wrap;
}

.amm-pagination-info {
    font-size: 0.875rem;
    color: var(--amm-muted);
}

.amm-pagination .amm-select {
    width: auto;
    padding: 0.375rem 0.75rem;
}

/* === Cards === */
.amm-card {
    background: var(--amm-bg);
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.amm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--amm-border);
}

.amm-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.amm-card-title .amm-badge {
    font-weight: 400;
    font-size: 0.75rem;
}

/* Document Input Cards */
.amm-doc-input-card {
    background: #f8fafc;
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    padding: 1rem;
}

.amm-doc-input-card .amm-or {
    margin: 0.75rem 0;
}

.amm-doc-field .amm-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* New Category Field */
.amm-new-category-field {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--amm-border);
}

.amm-label-sm {
    font-size: 0.8125rem;
    color: var(--amm-muted);
}

/* Form Actions */
.amm-form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--amm-border);
    flex-wrap: wrap;
}

.amm-form-actions .amm-hint {
    margin-left: auto;
    margin-top: 0;
}

/* === Stats Grid === */
.amm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.amm-stat {
    background: var(--amm-bg);
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    padding: 1.25rem;
    text-align: center;
}

.amm-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--amm-primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.amm-stat-label {
    font-size: 0.875rem;
    color: var(--amm-muted);
}

/* === Modal === */
.amm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.amm-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.amm-modal {
    background: var(--amm-bg);
    border-radius: var(--amm-radius);
    box-shadow: var(--amm-shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(-10px);
    transition: transform 0.2s ease;
}

.amm-modal-overlay.active .amm-modal {
    transform: scale(1) translateY(0);
}

.amm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--amm-border);
}

.amm-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.amm-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--amm-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.amm-modal-close:hover {
    color: var(--amm-danger);
}

.amm-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.amm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--amm-border);
    background: #f9fafb;
}

/* Modal Form Layout */
.amm-modal-form .amm-field {
    margin-bottom: 1rem;
}

.amm-modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 600px) {
    .amm-modal-row {
        grid-template-columns: 1fr;
    }
}

.amm-current-file {
    font-size: 0.875rem;
    color: var(--amm-accent);
    margin-bottom: 0.5rem;
}

.amm-current-file a {
    color: var(--amm-primary);
    font-weight: 500;
}

.amm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--amm-muted);
    margin-top: 0.5rem;
    cursor: pointer;
}

.amm-checkbox-label input {
    width: auto;
    margin: 0;
}

/* Wider modal for edit forms */
.amm-modal-overlay .amm-modal {
    max-width: 700px;
}

/* === Toasts === */
.amm-toasts {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 100000;
    pointer-events: none;
}

.amm-toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #1f2937;
    color: #fff;
    border-radius: var(--amm-radius);
    box-shadow: var(--amm-shadow-lg);
    font-size: 0.9375rem;
    pointer-events: auto;
    animation: amm-toast-in 0.3s ease;
}

.amm-toast.amm-toast-success {
    background: var(--amm-accent);
}

.amm-toast.amm-toast-error {
    background: var(--amm-danger);
}

.amm-toast.amm-toast-out {
    animation: amm-toast-out 0.3s ease forwards;
}

@keyframes amm-toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes amm-toast-out {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* === Notices === */
.amm-notice {
    padding: 1rem 1.25rem;
    border-radius: var(--amm-radius);
    margin-bottom: 1rem;
    border: 1px solid;
}

.amm-notice-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.amm-notice-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.amm-notice-warning {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.amm-notice-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

/* Login Required Notice */
.amm-login-required {
    max-width: 400px;
    margin: 3rem auto;
    text-align: center;
    padding: 2rem;
}

.amm-login-required p {
    margin: 0 0 1rem;
}

.amm-login-required p:last-child {
    margin-bottom: 0;
}

/* === Loading State === */
.amm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--amm-muted);
}

.amm-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--amm-border);
    border-top-color: var(--amm-primary);
    border-radius: 50%;
    animation: amm-spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

@keyframes amm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Empty State === */
.amm-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--amm-muted);
}

.amm-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.amm-empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--amm-text);
}

/* === Settings Form === */
.amm-settings-section {
    margin-bottom: 2rem;
}

.amm-settings-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--amm-border);
}

.amm-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.amm-color-input-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.amm-color-input-wrap input[type="color"] {
    width: 3rem;
    height: 2.5rem;
    padding: 0.25rem;
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    cursor: pointer;
}

.amm-color-input-wrap input[type="text"] {
    flex: 1;
}

/* === Checkbox/Toggle === */
.amm-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
}

.amm-checkbox input {
    margin-top: 0.25rem;
}

.amm-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.amm-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.amm-toggle-track {
    width: 2.75rem;
    height: 1.5rem;
    background: var(--amm-border);
    border-radius: 1rem;
    transition: background 0.2s ease;
}

.amm-toggle input:checked + .amm-toggle-track {
    background: var(--amm-primary);
}

.amm-toggle-thumb {
    position: absolute;
    left: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: left 0.2s ease;
}

.amm-toggle input:checked ~ .amm-toggle-thumb {
    left: 1.5rem;
}

/* === Screen reader only === */
.amm-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* === Hide page title === */
.amm-hide-title .entry-title,
.amm-hide-title .page-title,
.amm-hide-title h1.title {
    display: none !important;
}

/* === Board Package Styles === */
.amm-board-header {
    text-align: center;
    margin-bottom: 2rem;
}

.amm-meeting-selector {
    max-width: 800px;
    margin: 0 auto 2rem;
}

.amm-selector-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}

.amm-package-content {
    max-width: 1000px;
    margin: 0 auto;
}

.amm-package-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: var(--amm-radius);
    margin-bottom: 1.5rem;
}

.amm-package-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--amm-text);
    margin: 0 0 0.5rem;
}

.amm-package-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.amm-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.9375rem;
    color: var(--amm-muted);
}

.amm-package-actions {
    display: flex;
    gap: 0.5rem;
}

.amm-documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.amm-doc-card {
    position: relative;
    background: var(--amm-bg);
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.amm-doc-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.amm-doc-card.amm-doc-unavailable-card {
    opacity: 0.6;
}

.amm-doc-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--amm-border);
}

.amm-doc-icon {
    font-size: 1.75rem;
}

.amm-doc-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--amm-text);
}

.amm-doc-card-body {
    padding: 1.25rem;
}

.amm-doc-description {
    color: var(--amm-muted);
    font-size: 0.9375rem;
    margin: 0;
    line-height: 1.5;
}

.amm-doc-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--amm-border);
    background: #fafafa;
}

.amm-doc-card-footer .amm-btn {
    width: 100%;
}

.amm-doc-unavailable {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    color: var(--amm-muted);
    font-size: 0.9375rem;
}

.amm-doc-unavailable[hidden] {
    display: none !important;
}

.amm-doc-unavailable .amm-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.amm-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--amm-muted);
}

.amm-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.amm-empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--amm-text);
    margin: 0 0 0.5rem;
}

.amm-empty-state p {
    margin: 0;
    font-size: 1rem;
}

.amm-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--amm-text);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--amm-border);
}

.amm-docs-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.amm-docs-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
}

.amm-doc-item-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--amm-text);
}

.amm-doc-pending {
    opacity: 0.7;
}

.amm-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.amm-badge-muted {
    background: #e5e7eb;
    color: #6b7280;
}

.amm-badge-primary {
    background: rgba(59, 130, 246, 0.15);
    color: var(--amm-primary);
}

.amm-no-docs {
    text-align: center;
    padding: 1.5rem;
    color: var(--amm-muted);
    font-style: italic;
}

/* === Supporting Documents === */
.amm-supporting-docs-section {
    margin-top: 1.5rem;
}

.amm-supporting-docs-section .amm-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.amm-supporting-docs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.amm-supporting-doc-item {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--amm-border);
    border-radius: var(--amm-radius);
    align-items: start;
}

.amm-supporting-doc-item .amm-field {
    margin: 0;
}

.amm-supporting-doc-item .amm-label {
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
}

.amm-supporting-doc-item .amm-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.amm-supporting-doc-remove {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--amm-danger);
    cursor: pointer;
    border-radius: var(--amm-radius);
    transition: background 0.2s ease;
    margin-top: 1.5rem;
}

.amm-supporting-doc-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

.amm-supporting-doc-file-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.amm-supporting-doc-file-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.amm-supporting-doc-or {
    font-size: 0.75rem;
    color: var(--amm-muted);
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .amm-supporting-doc-item {
        grid-template-columns: 1fr;
    }
    
    .amm-supporting-doc-remove {
        margin-top: 0;
        justify-self: end;
    }
}

/* === Responsive adjustments === */
@media (max-width: 768px) {
    .amm-selector-row {
        grid-template-columns: 1fr;
    }
    
    .amm-package-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .amm-package-actions {
        width: 100%;
    }
    
    .amm-package-actions .amm-btn {
        flex: 1;
    }
}

@media (max-width: 640px) {
    .amm-filters {
        flex-direction: column;
    }
    
    .amm-filters .amm-form-group {
        width: 100%;
    }
    
    .amm-modal {
        max-height: 100vh;
        border-radius: 0;
    }
    
    .amm-navbar {
        flex-direction: column;
    }
    
    .amm-table th,
    .amm-table td {
        padding: 0.5rem 0.75rem;
    }
}

/* === Print Stylesheet === */
@media print {
    /* Hide non-content elements */
    .amm-nav,
    .amm-navbar,
    .amm-filters,
    .amm-filters-grid,
    .amm-pagination,
    .amm-form-actions,
    .amm-btn-group,
    .amm-supporting-docs-section,
    .amm-new-category-field,
    .amm-skip-link,
    .amm-toasts,
    .amm-meeting-selector,
    .amm-package-actions button:not(#amm-print-package),
    #amm-download-all,
    #amm-print-package,
    #amm-download-csv,
    #amm-manage-export,
    .amm-actions-cell,
    .amm-per-page,
    .amm-nav-user,
    .amm-navbar-user,
    .amm-navbar-spacer {
        display: none !important;
    }

    /* Reset backgrounds and shadows */
    .amm-container,
    .amm-wrap,
    .amm-card,
    .amm-table,
    .amm-doc-card {
        background: #fff !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    /* Ensure text is dark and readable */
    body,
    .amm-container,
    .amm-wrap,
    .amm-title,
    .amm-subtitle,
    .amm-text-muted,
    .amm-stat-label,
    .amm-stat-value,
    .amm-table th,
    .amm-table td,
    .amm-doc-card-title,
    .amm-doc-description,
    .amm-package-title,
    .amm-meta-value {
        color: #000 !important;
    }

    /* Table styling for print */
    .amm-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .amm-table th,
    .amm-table td {
        border: 1px solid #999 !important;
        padding: 6px 10px !important;
    }

    .amm-table thead th {
        background: #eee !important;
        font-weight: bold !important;
    }

    /* Expand links to show URLs */
    .amm-doc-link::after,
    .amm-doc-card-footer a::after {
        content: " (" attr(href) ")";
        font-size: 0.75em;
        color: #666;
        word-break: break-all;
    }

    /* Board Package print layout */
    .amm-package-content {
        page-break-inside: avoid;
    }

    .amm-documents-grid {
        display: block !important;
    }

    .amm-doc-card {
        page-break-inside: avoid;
        margin-bottom: 1rem !important;
    }

    .amm-additional-docs {
        page-break-before: auto;
    }

    .amm-docs-list-item {
        border-bottom: 1px solid #ccc !important;
        padding: 0.5rem 0 !important;
    }

    /* Page margins */
    @page {
        margin: 0.75in;
    }
}

/* === Sortable header keyboard/aria styles === */
.amm-sortable[aria-sort="ascending"] .amm-sort-icon::after {
    content: " ▲";
}

.amm-sortable[aria-sort="descending"] .amm-sort-icon::after {
    content: " ▼";
}

.amm-sortable[aria-sort="none"] .amm-sort-icon::after {
    content: "";
}

.amm-sortable {
    cursor: pointer;
    user-select: none;
}

.amm-sortable:focus-visible {
    outline: 2px solid var(--amm-primary);
    outline-offset: -2px;
}
