/**
 * Troop 70 Outing Planner - Local stylesheet
 * System Version: 6.0.0
 * Loaded BEFORE the Tailwind runtime. Provides:
 *   - system font stack (no external font request)
 *   - toast / dialog / save-indicator components used by assets/app.js
 *   - DataTables theme overrides
 *   - a readable fallback layout if the Tailwind CDN fails (html.tw-failed)
 */

body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Only needed when Tailwind failed to load; a global !important would break responsive "hidden md:flex". */
html.tw-failed .hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn  { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.animate-fade-in { animation: fadeIn 0.2s ease-out forwards; }
.animate-pop-in  { animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

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

/* Visible keyboard focus everywhere */
:focus-visible { outline: 2px solid #15803d; outline-offset: 2px; }

/* ---------------------------------------------------------------- Toasts */
.app-toast-host {
    position: fixed; right: 16px; bottom: 16px; z-index: 10000;
    display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
}
.app-toast {
    display: flex; align-items: flex-start; gap: 10px;
    background: #1c1917; color: #fff; border-radius: 12px; padding: 12px 14px;
    font-size: 13px; line-height: 1.45; box-shadow: 0 10px 25px rgba(0,0,0,.25);
    animation: popIn .2s ease-out; border-left: 4px solid #a8a29e;
}
.app-toast i { margin-top: 2px; }
.app-toast span { flex: 1; }
.app-toast-success { border-left-color: #22c55e; }
.app-toast-success i { color: #4ade80; }
.app-toast-error   { border-left-color: #f43f5e; }
.app-toast-error i { color: #fb7185; }
.app-toast-warning { border-left-color: #f59e0b; }
.app-toast-warning i { color: #fbbf24; }
.app-toast-action { background: #fff; color: #1c1917; border: 0; border-radius: 8px; padding: 3px 10px; font-weight: 700; cursor: pointer; font-size: 12px; }
.app-toast-close { background: none; border: 0; color: #a8a29e; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.app-toast-close:hover { color: #fff; }
.app-toast-out { opacity: 0; transition: opacity .2s; }

/* ---------------------------------------------------------------- Confirm dialog */
.app-dialog { border: 0; border-radius: 16px; padding: 0; max-width: 420px; width: calc(100vw - 32px); box-shadow: 0 25px 50px rgba(0,0,0,.3); }
.app-dialog::backdrop { background: rgba(28,25,23,.7); backdrop-filter: blur(2px); }
.app-dialog form { padding: 22px; }
.app-dialog-title { margin: 0 0 6px; font-size: 15px; font-weight: 800; color: #1c1917; }
.app-dialog-msg { margin: 0 0 18px; font-size: 14px; color: #44403c; line-height: 1.5; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.app-btn { font: inherit; font-size: 13px; font-weight: 700; padding: 8px 16px; border-radius: 10px; border: 1px solid #d6d3d1; background: #fff; color: #292524; cursor: pointer; }
.app-btn-primary { background: #15803d; border-color: #15803d; color: #fff; }
.app-btn-danger  { background: #e11d48; border-color: #e11d48; color: #fff; }

/* ---------------------------------------------------------------- Save indicator */
#app-save-indicator { font-size: 11px; font-weight: 700; letter-spacing: .03em; }
#app-save-indicator[data-state="saving"]  { color: #b45309; }
#app-save-indicator[data-state="pending"] { color: #be123c; }
#app-save-indicator[data-state="saved"]   { color: #15803d; }
.field-saving { border-color: #f59e0b !important; background-color: #fffbeb !important; }
.field-error  { border-color: #e11d48 !important; background-color: #fff1f2 !important; }
.field-saved  { border-color: #22c55e !important; transition: border-color 1.2s; }

/* ---------------------------------------------------------------- DataTables theme */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #d6d3d1 !important; border-radius: .6rem !important;
    padding: .35rem .75rem !important; font-size: .8rem !important; background: #fff !important; margin-bottom: 10px;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus { border-color: #15803d !important; outline: none; box-shadow: 0 0 0 2px rgba(21,128,61,.25); }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: .5rem !important; font-size: .75rem !important; padding: .25rem .6rem !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #15803d !important; color: #fff !important; border: 1px solid #15803d !important; font-weight: 700 !important;
}
table.dataTable thead th {
    background-color: #f8f6f4 !important; color: #1c1917 !important; font-weight: 900 !important;
    text-transform: uppercase !important; font-size: 10px !important; letter-spacing: .05em !important;
    border-bottom: 2px solid #e7e5e4 !important;
}
table.dataTable.no-footer { border-bottom: 1px solid #e7e5e4 !important; }

/* ---------------------------------------------------------------- Print */
@media print {
    .no-print, .dataTables_length, .dataTables_filter, .dataTables_paginate, .dataTables_info, .app-toast-host { display: none !important; }
    body, main { background: #fff !important; color: #000 !important; }
}

/* ---------------------------------------------------------------- CDN failure fallback */
html.tw-failed body { background: #f5f5f4; color: #1c1917; margin: 0; }
html.tw-failed header { background: #14532d; color: #fff; padding: 12px 16px; }
html.tw-failed main { max-width: 1100px; margin: 0 auto; padding: 16px; }
html.tw-failed section { background: #fff; border: 1px solid #e7e5e4; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
html.tw-failed input[type="text"], html.tw-failed input[type="email"], html.tw-failed input[type="password"],
html.tw-failed input[type="datetime-local"], html.tw-failed select, html.tw-failed textarea {
    display: block; width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d6d3d1; border-radius: 8px; font: inherit; margin: 4px 0 12px;
}
html.tw-failed button, html.tw-failed a.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid #a8a29e; background: #fff; cursor: pointer; font: inherit; }
html.tw-failed label { display: block; font-weight: 700; font-size: 13px; }
html.tw-failed table { width: 100%; border-collapse: collapse; }
html.tw-failed td, html.tw-failed th { border-bottom: 1px solid #e7e5e4; padding: 8px; text-align: left; }
html.tw-failed [class*="fixed"][class*="inset-0"] { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 9999; }
html.tw-failed [class*="fixed"][class*="inset-0"] > div { background: #fff; border-radius: 12px; max-width: 440px; width: 100%; padding: 16px; }
