/*
 * Styles for the appointment-list frontend (index.html).
 *
 * The Generate PDF view keeps the historical single-file look; the catalog
 * view reuses the same palette and form controls, so both read as one page.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
}
.container {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 640px;
}
/* The catalog table needs more room than the PDF form. */
.container.wide {
    max-width: 1080px;
}
h1 {
    font-size: 24px;
    color: #1a1a2e;
    text-align: center;
    margin-bottom: 6px;
}
.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 28px;
    font-size: 14px;
}
.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: #1a1a2e;
}
input[type="file"],
select,
input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}
input[type="file"]:focus,
select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
    border-color: #3b82f6;
    outline: none;
}
small {
    display: block;
    margin-top: 4px;
    color: #888;
    font-size: 12px;
}
.hidden { display: none; }

/* --- Buttons -----------------------------------------------------------------
   Base buttons are the full-width primary action (Generate PDF, form submits).
   Toolbar, tab and row buttons override width and spacing below. */

button {
    width: 100%;
    padding: 14px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}
button:hover { background: #2563eb; }
button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary:disabled,
.btn-danger:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* --- Status boxes (PDF view, catalog view, modal) ----------------------------- */

#status,
#catalogStatus,
#modalStatus {
    display: none;
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}
#status.show,
#catalogStatus.show,
#modalStatus.show { display: block; }
#status.success, #catalogStatus.success, #modalStatus.success {
    background: #dcfce7; color: #166534; border: 1px solid #86efac;
}
#status.error, #catalogStatus.error, #modalStatus.error {
    background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
}
#status.info, #catalogStatus.info, #modalStatus.info {
    background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.api-status {
    text-align: center;
    font-size: 12px;
    margin-bottom: 20px;
    padding: 6px 12px;
    border-radius: 6px;
}
.api-status.online  { background: #dcfce7; color: #166534; }
.api-status.offline { background: #fee2e2; color: #991b1b; }
.api-status.checking { background: #f3f4f6; color: #666; }

/* --- Tabs --------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}
.tab {
    width: auto;
    margin-top: 0;
    padding: 10px 18px;
    background: transparent;
    color: #666;
    border: none;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
}
.tab:hover { background: #f3f4f6; }
.tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

/* --- Catalog toolbar ----------------------------------------------------------- */

.catalog-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.catalog-toolbar input[type="text"],
.catalog-toolbar select {
    width: auto;
    flex: 1 1 220px;
}
.catalog-toolbar button {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 10px 14px;
    font-size: 14px;
}
.catalog-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
}

/* --- Catalog table --------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th, td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    vertical-align: middle;
}
th {
    background: #f8fafc;
    color: #1a1a2e;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.cell-wrap { white-space: normal; min-width: 180px; }
.cell-date { color: #666; font-size: 12px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-size: 12px;
    font-weight: 600;
}
/* Off-list ubicacion: accepted, but flagged so the operator sees why the PDF
   prints it in the trailing group. */
.badge.offlist {
    background: #fef3c7;
    color: #92400e;
}

.row-actions { white-space: nowrap; }
.row-actions button {
    width: auto;
    margin-top: 0;
    margin-right: 6px;
    padding: 6px 10px;
    font-size: 12px;
}
.row-actions button:last-child { margin-right: 0; }

/* Import result warnings (one line per skipped/odd row). */
.warnings-list {
    margin-top: 8px;
    max-height: 180px;
    overflow-y: auto;
    text-align: left;
    font-size: 12px;
    list-style-position: inside;
}
.warnings-list li { margin-bottom: 2px; }

/* --- Access token box -------------------------------------------------------------- */

.token-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}
.token-box summary {
    cursor: pointer;
    font-weight: 600;
    color: #1a1a2e;
}
.token-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}
.token-row input {
    flex: 1 1 240px;
    width: auto;
}
.token-row button {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 8px 14px;
    font-size: 13px;
}
.token-hint {
    margin-top: 8px;
    color: #888;
    font-size: 12px;
}

/* --- Create/edit modal ---------------------------------------------------------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal h2 {
    font-size: 18px;
    color: #1a1a2e;
    margin-bottom: 18px;
}
#modalStatus { margin-top: 0; margin-bottom: 14px; }
.modal-actions {
    display: flex;
    gap: 10px;
}
.modal-actions button { margin-top: 8px; }

/* Inline notice under the free-text ubicacion input. */
.offlist-warning { color: #92400e; }
