/* ============================================================
   ACE - Accurate Claims Examiner
   Navy / Steel-Blue palette with CSS custom properties
   ============================================================ */

:root {
    --ao-navy:        #1b2a4a;
    --ao-navy-dark:   #111d35;
    --ao-navy-light:  #243556;
    --ao-steel:       #4a6fa5;
    --ao-steel-light: #6b8fc5;
    --ao-accent:      #2196f3;
    --ao-accent-hover:#1976d2;
    --ao-success:     #28a745;
    --ao-danger:      #dc3545;
    --ao-warning:     #ffc107;
    --ao-info:        #17a2b8;
    --ao-text:        #2c3e50;
    --ao-text-muted:  #6c757d;
    --ao-bg:          #f4f6f9;
    --ao-white:       #ffffff;
    --ao-border:      #dee2e6;
    --ao-shadow:      0 2px 8px rgba(27, 42, 74, 0.10);
    --ao-shadow-lg:   0 4px 16px rgba(27, 42, 74, 0.15);
    --ao-radius:      0.5rem;
    --ao-transition:  0.2s ease;
}

/* ---- Base ---- */
html {
    font-size: 14px;
    min-height: 100%;
}
@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--ao-bg);
    color: var(--ao-text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--ao-steel);
    transition: color var(--ao-transition);
}
a:hover { color: var(--ao-accent-hover); }

/* ---- Focus rings ---- */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 0.1rem var(--ao-white), 0 0 0 0.25rem var(--ao-steel-light);
}

/* ---- Navbar ---- */
.navbar {
    background: linear-gradient(135deg, var(--ao-navy-dark), var(--ao-navy)) !important;
    box-shadow: var(--ao-shadow-lg);
}
.navbar-brand {
    white-space: normal;
    text-align: center;
    word-break: break-all;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.ace-spade {
    color: var(--ao-steel-light);
    font-size: 1.3em;
    margin-right: 2px;
    vertical-align: -1px;
}
.navbar .nav-link {
    transition: color var(--ao-transition), background var(--ao-transition);
    border-radius: var(--ao-radius);
    padding: 0.4rem 0.75rem !important;
}
.navbar .nav-link:hover {
    background: rgba(255,255,255,0.08);
}

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: var(--ao-radius);
    box-shadow: var(--ao-shadow);
    transition: box-shadow var(--ao-transition), transform var(--ao-transition);
}
.card:hover {
    box-shadow: var(--ao-shadow-lg);
}
.card-header {
    background: var(--ao-navy);
    color: var(--ao-white);
    border-radius: var(--ao-radius) var(--ao-radius) 0 0 !important;
    font-weight: 600;
}
.card-header.bg-dark {
    background: var(--ao-navy) !important;
}
.card-header.bg-primary {
    background: var(--ao-steel) !important;
}

/* ---- Buttons ---- */
.btn-primary {
    background: var(--ao-steel);
    border-color: var(--ao-steel);
    transition: all var(--ao-transition);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--ao-accent-hover);
    border-color: var(--ao-accent-hover);
    transform: translateY(-1px);
}
.btn-outline-primary {
    color: var(--ao-steel);
    border-color: var(--ao-steel);
}
.btn-outline-primary:hover {
    background: var(--ao-steel);
    border-color: var(--ao-steel);
    color: var(--ao-white);
}
.btn-outline-warning {
    color: #e67e22;
    border-color: #e67e22;
}
.btn-outline-warning:hover {
    background: #e67e22;
    border-color: #e67e22;
    color: var(--ao-white);
}

/* ---- Tables ---- */
.table {
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    border-bottom: 2px solid var(--ao-steel);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem;
}
.table-dark, .table thead.table-dark th {
    background: var(--ao-navy) !important;
    color: var(--ao-white);
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(74, 111, 165, 0.04);
}
.table-hover > tbody > tr:hover > * {
    background-color: rgba(74, 111, 165, 0.08);
}
.table td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
}

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    letter-spacing: 0.3px;
}

/* ---- Alerts ---- */
.alert {
    border-radius: var(--ao-radius);
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ---- Footer ---- */
.footer {
    margin-top: auto;
    width: 100%;
    white-space: nowrap;
    padding: 0.5rem 0;
    background: var(--ao-white);
    border-top: 1px solid var(--ao-border) !important;
    font-size: 0.875rem;
}

/* ---- Pagination ---- */
.page-link {
    color: var(--ao-steel);
}
.page-item.active .page-link {
    background-color: var(--ao-steel);
    border-color: var(--ao-steel);
}

/* ---- Nav pills (used in admin) ---- */
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
    background-color: var(--ao-steel);
    border-color: var(--ao-steel);
    color: var(--ao-white);
}

/* ============================================================
   Environment Indicator Bar
   ============================================================ */
.env-bar {
    height: 4px;
    width: 100%;
    position: relative;
    z-index: 1100;
}
.env-bar--local   { background: var(--ao-warning); }
.env-bar--uat     { background: var(--ao-success); }
.env-bar--prod    { display: none; }

/* ============================================================
   Toast Notifications
   ============================================================ */
.ao-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.ao-toast {
    min-width: 300px;
    max-width: 420px;
    padding: 0.875rem 1.25rem;
    border-radius: var(--ao-radius);
    color: var(--ao-white);
    font-size: 0.9rem;
    box-shadow: var(--ao-shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
    animation: aoToastIn 0.3s ease forwards;
    cursor: pointer;
}
.ao-toast--removing {
    animation: aoToastOut 0.3s ease forwards;
}
.ao-toast--success  { background: var(--ao-success); }
.ao-toast--error    { background: var(--ao-danger); }
.ao-toast--info     { background: var(--ao-info); }
.ao-toast--warning  { background: #e67e22; }

.ao-toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.ao-toast-msg  { flex: 1; }

@keyframes aoToastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes aoToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================================
   Loading Overlay
   ============================================================ */
.ao-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(27, 42, 74, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.ao-loading-overlay.active { opacity: 1; }

.ao-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: var(--ao-white);
    border-radius: 50%;
    animation: aoSpin 0.7s linear infinite;
}
@keyframes aoSpin {
    to { transform: rotate(360deg); }
}

/* Form submit spinner inside buttons */
.ao-btn-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: aoSpin 0.7s linear infinite;
    vertical-align: -0.15em;
    margin-left: 0.4em;
}

/* ============================================================
   AO Grid Component
   Professional data grid with toolbar, sticky header,
   grid lines, row hover, and footer bar
   ============================================================ */

/* -- Grid container -- */
.ao-grid {
    border: 1px solid var(--ao-border);
    border-radius: var(--ao-radius);
    overflow: hidden;
    background: var(--ao-white);
    box-shadow: var(--ao-shadow);
}

/* -- Toolbar (top bar with title / count / actions) -- */
.ao-grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.875rem;
    background: var(--ao-navy);
    color: var(--ao-white);
    font-size: 0.85rem;
    min-height: 40px;
}
.ao-grid-toolbar-title {
    font-weight: 600;
    letter-spacing: 0.3px;
}
.ao-grid-toolbar-count {
    opacity: 0.75;
    font-size: 0.8rem;
}

/* -- Table overrides inside ao-grid -- */
.ao-grid .table {
    margin-bottom: 0;
    border-collapse: collapse;
}

/* Sticky header */
.ao-grid .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--ao-navy-light);
    color: var(--ao-white);
    border-bottom: 2px solid var(--ao-steel);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}

/* Vertical grid lines */
.ao-grid .table th + th,
.ao-grid .table td + td {
    border-left: 1px solid rgba(0, 0, 0, 0.06);
}
.ao-grid .table thead th + th {
    border-left-color: rgba(255, 255, 255, 0.12);
}

/* Body cells */
.ao-grid .table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--ao-border);
    font-size: 0.875rem;
}

/* Zebra striping */
.ao-grid .table tbody tr:nth-child(even) {
    background: rgba(74, 111, 165, 0.03);
}

/* Row hover */
.ao-grid .table tbody tr {
    transition: background var(--ao-transition), border-color var(--ao-transition);
    border-left: 3px solid transparent;
}
.ao-grid .table tbody tr:hover {
    background: rgba(74, 111, 165, 0.08);
    border-left-color: var(--ao-steel);
}

/* Last row no bottom border (footer handles it) */
.ao-grid .table tbody tr:last-child td {
    border-bottom: none;
}

/* -- Scrollable body for tall grids -- */
.ao-grid .table-responsive {
    max-height: 600px;
    overflow-y: auto;
}

/* -- Footer bar -- */
.ao-grid-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.875rem;
    background: #eef1f6;
    border-top: 1px solid var(--ao-border);
    font-size: 0.8rem;
    color: var(--ao-text-muted);
    min-height: 36px;
}
.ao-grid-footer .pagination {
    margin-bottom: 0;
}

/* -- Compact variant for admin grids -- */
.ao-grid--compact .table td {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
}
.ao-grid--compact .table thead th {
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
}

/* -- Action cell: tighter button spacing -- */
.ao-grid .table td:last-child .btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.78rem;
}
.ao-grid .table td:last-child .btn + .btn,
.ao-grid .table td:last-child .btn + form,
.ao-grid .table td:last-child form + .btn {
    margin-left: 0.25rem;
}
.ao-grid .table td:last-child form {
    display: inline;
}

/* ---- Utility: text truncate with ellipsis ---- */
.text-truncate-ao {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* ---- Cookie consent / accept policy button (kept from default) ---- */
button.accept-policy {
    font-size: 1rem;
    line-height: inherit;
}
