/* Aliados Appointments — same visual system as aliados-bookkeeping:
   direct hex values, no custom properties, EXCEPT on the public booking
   page, where --aap-primary/--aap-accent/--aap-accent-rgb/--aap-accent-dark
   are read from the preparer's Business Profile (when they have one) via
   an inline style on #aapPublicApp. Every var() below carries the current
   hardcoded color as its fallback, so nothing changes for the admin panel
   or for a preparer who never touched Business Profile. */

.aap-app {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #0f172a;
    background: #F5F5F5;
    padding: 18px;
    border-radius: 14px;
    box-sizing: border-box;
    max-width: 960px;
    margin: 0 auto;
}

.aap-app * { box-sizing: border-box; }

.aap-notice {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 14px;
    padding: 24px;
    text-align: center;
}

/* Topbar */
.aap-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.aap-topbar h2 {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: var(--aap-primary, #1C2D4A);
    margin: 0;
}

.aap-embed .aap-topbar { display: none; }

/* Public link box */
.aap-link-box {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.aap-link-box-label {
    font-weight: 700;
    color: #1C2D4A;
    font-size: 13px;
    margin-bottom: 8px;
}

.aap-link-box-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aap-link-box-row .aap-input {
    flex: 1;
    min-width: 200px;
}

/* Tabs */
.aap-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border-radius: 999px;
    padding: 6px;
    margin-bottom: 16px;
    border: 1px solid rgba(15, 23, 42, .08);
}

.aap-tab {
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    color: #1C2D4A;
    cursor: pointer;
}

.aap-tab.is-active {
    background: #1C2D4A;
    color: #fff;
}

.aap-tab-help {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, .12);
    background: #fff;
    color: #1C2D4A;
    font-weight: 900;
    cursor: pointer;
}
.aap-tab-help:hover {
    background: #1C2D4A;
    color: #fff;
    border-color: #1C2D4A;
}

/* Panels */
.aap-panel { display: none; }
.aap-panel.is-active { display: block; }

.aap-panel-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.aap-panel-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #1C2D4A;
}

.aap-mt { margin-top: 24px; }

/* Inputs / buttons */
.aap-input {
    border: 1px solid rgba(15, 23, 42, .15);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #0f172a;
}
.aap-input:focus {
    outline: none;
    border-color: var(--aap-accent, #00BFA5);
}

.aap-btn {
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

.aap-btn-primary {
    background: var(--aap-accent, #00BFA5);
    color: #fff;
}
.aap-btn-primary:hover { background: var(--aap-accent-dark, #00a693); }

.aap-btn-secondary {
    background: #fff;
    color: var(--aap-primary, #1C2D4A);
    border: 1px solid rgba(15, 23, 42, .15);
}
.aap-btn-secondary:hover { background: #f0f0f0; }

.aap-btn-danger {
    background: #fff;
    color: #c0392b;
    border: 1px solid rgba(192, 57, 43, .3);
}
.aap-btn-danger:hover { background: #fdecea; }

/* Appointment list */
.aap-appt-list, .aap-types-list, .aap-blocked-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aap-card {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.aap-card-main { flex: 1; min-width: 200px; }

.aap-card-title {
    font-weight: 700;
    color: #1C2D4A;
    font-size: 14px;
}

.aap-card-sub {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.aap-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.aap-badge-confirmed { background: rgba(0,191,165,.15); color: #00806e; }
.aap-badge-completed { background: rgba(28,45,74,.1); color: #1C2D4A; }
.aap-badge-cancelled { background: rgba(192,57,43,.12); color: #c0392b; }
.aap-badge-no_show   { background: rgba(249,168,37,.15); color: #a86b00; }

.aap-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aap-card-actions select {
    border: 1px solid rgba(15,23,42,.15);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
}

/* Citas panel: toolbar (view toggle + Nueva Cita) */
.aap-appt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.aap-view-toggle {
    display: inline-flex;
    gap: 6px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .1);
    border-radius: 999px;
    padding: 4px;
}

.aap-view-btn {
    border: none;
    background: transparent;
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    color: #1C2D4A;
    cursor: pointer;
}
.aap-view-btn.is-active {
    background: #00BFA5;
    color: #fff;
}

.aap-appt-view { display: none; }
.aap-appt-view.is-active { display: block; }

/* Week calendar grid */
.aap-week-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.aap-week-label {
    font-weight: 800;
    color: #1C2D4A;
    font-size: 14px;
    flex: 1;
    text-align: center;
}

.aap-week-grid-wrap {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 12px;
    overflow: hidden;
}

.aap-week-grid-header {
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
    border-bottom: 1px solid rgba(15, 23, 42, .1);
    background: #F5F5F5;
}

.aap-week-grid-header-cell {
    padding: 10px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #1C2D4A;
}
.aap-week-grid-header-cell .aap-week-day-date {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-top: 2px;
}
.aap-week-grid-header-cell.is-today {
    background: rgba(0,191,165,.12);
    border-radius: 8px;
}

.aap-week-grid-body {
    position: relative;
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
    max-height: 620px;
    overflow-y: auto;
}

.aap-week-hour-col {
    display: flex;
    flex-direction: column;
}

.aap-week-hour-label {
    height: 44px;
    font-size: 10px;
    color: #94a3b8;
    text-align: right;
    padding-right: 6px;
    box-sizing: border-box;
    border-top: 1px solid rgba(15, 23, 42, .06);
    transform: translateY(-6px);
}

.aap-week-day-col {
    position: relative;
    border-left: 1px solid rgba(15, 23, 42, .06);
}

.aap-week-day-col.is-today { background: rgba(0,191,165,.04); }

.aap-week-hour-row {
    height: 44px;
    border-top: 1px solid rgba(15, 23, 42, .06);
    box-sizing: border-box;
}

.aap-week-event {
    position: absolute;
    left: 3px;
    right: 3px;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
    cursor: pointer;
    border-left: 3px solid #00806e;
    background: rgba(0,191,165,.16);
    color: #00453d;
}
.aap-week-event-confirmed { border-left-color: #00806e; background: rgba(0,191,165,.16); color: #00453d; }
.aap-week-event-completed { border-left-color: #1C2D4A; background: rgba(28,45,74,.1); color: #1C2D4A; }
.aap-week-event-cancelled { border-left-color: #c0392b; background: rgba(192,57,43,.12); color: #8f2c20; text-decoration: line-through; }
.aap-week-event-no_show   { border-left-color: #a86b00; background: rgba(249,168,37,.16); color: #7a4f00; }

.aap-week-event-name { font-weight: 700; display: block; }
.aap-week-event-time { display: block; opacity: .85; }

.aap-appt-detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(15, 23, 42, .06);
}
.aap-appt-detail-row:last-child { border-bottom: none; }
.aap-appt-detail-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
}

/* CRM contact search (New Appointment modal) */
.aap-crm-search-wrap { position: relative; }

.aap-crm-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 20;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 10px;
    margin-top: 4px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .12);
    display: none;
}
.aap-crm-search-results.is-open { display: block; }

.aap-crm-search-result-item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(15, 23, 42, .06);
}
.aap-crm-search-result-item:last-child { border-bottom: none; }
.aap-crm-search-result-item:hover { background: #F5F5F5; }
.aap-crm-search-result-name { font-weight: 700; color: #1C2D4A; font-size: 13px; }
.aap-crm-search-result-sub { font-size: 11px; color: #64748b; }

.aap-crm-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(0,191,165,.08);
    border: 1px solid rgba(0,191,165,.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 6px;
    font-size: 13px;
    color: #00594e;
}
.aap-crm-selected button {
    border: none;
    background: transparent;
    color: #00594e;
    font-weight: 700;
    cursor: pointer;
}

.aap-crm-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #00806e;
    background: rgba(0,191,165,.15);
    border-radius: 999px;
    padding: 2px 8px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Weekly grid */
.aap-weekly-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.aap-weekly-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 10px;
    padding: 10px 14px;
    flex-wrap: wrap;
}

.aap-weekly-row-day {
    width: 100px;
    font-weight: 700;
    color: #1C2D4A;
    font-size: 13px;
}

.aap-weekly-windows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.aap-weekly-window {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modal */
.aap-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.aap-modal-overlay.is-open { display: flex; }

.aap-modal {
    background: #fff;
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.aap-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(15, 23, 42, .08);
    font-weight: 800;
    color: #1C2D4A;
    font-family: 'Poppins', sans-serif;
}

.aap-modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}

.aap-modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aap-modal-body label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1C2D4A;
}

.aap-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid rgba(15, 23, 42, .08);
}

/* Public booking page */
.aap-public { max-width: 600px; }

.aap-public-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.aap-public-brand img {
    max-height: 70px;
    max-width: 259px;
    object-fit: contain;
    border-radius: 6px;
}
.aap-embed .aap-public-brand { display: none; }

.aap-booking-steps .aap-step { display: none; }
.aap-booking-steps .aap-step.is-active { display: block; }

.aap-booking-steps h3 {
    font-family: 'Poppins', sans-serif;
    color: var(--aap-primary, #1C2D4A);
    font-size: 17px;
    margin: 0 0 12px;
}

.aap-ai-box {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aap-ai-box label {
    font-size: 13px;
    font-weight: 600;
    color: var(--aap-primary, #1C2D4A);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aap-ai-result {
    background: rgba(var(--aap-accent-rgb, 0,191,165), .08);
    border: 1px solid rgba(var(--aap-accent-rgb, 0,191,165), .25);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--aap-accent-dark, #00594e);
}

.aap-type-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.aap-type-option {
    background: #fff;
    border: 2px solid rgba(15, 23, 42, .1);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.aap-type-option.is-selected {
    border-color: var(--aap-accent, #00BFA5);
    background: rgba(var(--aap-accent-rgb, 0,191,165), .06);
}

.aap-type-option-name {
    font-weight: 700;
    color: var(--aap-primary, #1C2D4A);
    font-size: 14px;
}

.aap-type-option-desc {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.aap-type-option-duration {
    font-size: 12px;
    font-weight: 700;
    color: var(--aap-accent-dark, #00806e);
    white-space: nowrap;
}

.aap-slot-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.aap-next-available {
    margin-top: 14px;
}
.aap-next-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.aap-slot-btn {
    border: 1px solid rgba(15, 23, 42, .15);
    background: #fff;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--aap-primary, #1C2D4A);
}
.aap-slot-btn.is-selected {
    background: var(--aap-primary, #1C2D4A);
    color: #fff;
    border-color: var(--aap-primary, #1C2D4A);
}

.aap-booking-steps label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--aap-primary, #1C2D4A);
    margin-bottom: 12px;
}

.aap-confirm-box {
    background: #fff;
    border: 1px solid rgba(var(--aap-accent-rgb, 0,191,165), .3);
    border-radius: 14px;
    padding: 24px;
    text-align: center;
}
.aap-confirm-box h3 {
    color: var(--aap-accent-dark, #00806e);
    margin-bottom: 8px;
}

.aap-step-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}

@media (max-width: 600px) {
    .aap-weekly-row { flex-direction: column; align-items: flex-start; }
    .aap-weekly-row-day { width: auto; }
}
