/* ── Variables ───────────────────────────────────────── */
:root {
    --accent-red: #c44536;
    --gradient-red: linear-gradient(135deg, #c44536, #d95f4e);
    --dark-bg: #0a0a0a;
    --dark-card: #111111;
    --dark-card-border: rgba(255, 255, 255, 0.07);
    --text-secondary: #a0a0a0;
    --text-muted: #5a5a5a;
}

/* ── Base ────────────────────────────────────────────── */
body {
    font-family: 'Raleway', sans-serif;
    background: var(--dark-bg);
    min-height: 100vh;
    padding: 80px 20px 60px;
}

/* ── Background decorations ──────────────────────────── */
.page-bg-glow {
    position: fixed;
    top: 0;
    right: 0;
    width: 65vw;
    height: 65vh;
    background: radial-gradient(ellipse at 75% 15%, rgba(196, 69, 54, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.page-bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: radial-gradient(ellipse at center, black 5%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, black 5%, transparent 75%);
}

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
    background-color: rgba(10, 10, 10, 0.95) !important;
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-brand {
    display: flex;
    align-items: center;
}

.navbar-logo-icon {
    height: 40px;
    width: 40px;
    padding: 5px;
    background: var(--gradient-red);
    border-radius: 10px;
    margin-right: 0.75rem;
    object-fit: contain;
}

.navbar-logo-text {
    height: 40px;
}

/* ── Page container ──────────────────────────────────── */
.turnos-container {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ── Header ──────────────────────────────────────────── */
.turnos-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.turnos-eyebrow {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent-red);
    background: rgba(196, 69, 54, 0.1);
    border: 1px solid rgba(196, 69, 54, 0.25);
    border-radius: 20px;
    padding: 0.35rem 1rem;
    margin-bottom: 1rem;
}

.turnos-title {
    color: #fff;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.turnos-title .gradient-text {
    background: linear-gradient(135deg, #c44536, #e07b6e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.turnos-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ── Toolbar ─────────────────────────────────────────── */
.turnos-toolbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn-new-turno {
    white-space: nowrap;
    flex-shrink: 0;
}

.turnos-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
    background: var(--gradient-red) !important;
    border: none !important;
    color: white !important;
    font-weight: 600;
    border-radius: 50px;
    padding: 0.65rem 1.5rem;
    box-shadow: 0 4px 16px rgba(196, 69, 54, 0.3);
    transition: all 0.25s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(196, 69, 54, 0.45);
}

.btn-outline-crm {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: var(--text-secondary) !important;
    border-radius: 50px;
    padding: 0.6rem 1.4rem;
    font-weight: 600;
    transition: border-color 0.2s, color 0.2s !important;
}

.btn-outline-crm:hover {
    border-color: rgba(255, 255, 255, 0.35) !important;
    color: #fff !important;
}

.btn-delete-turno {
    margin-right: auto;
    border-radius: 50px;
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

/* ── Calendar wrapper ────────────────────────────────── */
.calendar-wrapper {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 2rem;
    overflow: hidden;
}

/* FullCalendar theme overrides */
.fc {
    font-family: 'Raleway', sans-serif;
}

.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid {
    border-color: rgba(255, 255, 255, 0.06);
}

.fc .fc-toolbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.fc .fc-button {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-secondary) !important;
    font-family: 'Raleway', sans-serif !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    border-radius: 8px !important;
    padding: 0.4rem 0.85rem !important;
    transition: all 0.2s !important;
    box-shadow: none !important;
}

.fc .fc-button:hover,
.fc .fc-button-active {
    background: rgba(196, 69, 54, 0.2) !important;
    border-color: rgba(196, 69, 54, 0.4) !important;
    color: #fff !important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: rgba(196, 69, 54, 0.3) !important;
    border-color: rgba(196, 69, 54, 0.6) !important;
    color: #fff !important;
}

.fc .fc-today-button:disabled {
    opacity: 0.4 !important;
}

.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number,
.fc .fc-timegrid-slot-label-cushion,
.fc .fc-timegrid-axis-cushion {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-decoration: none;
}

.fc .fc-daygrid-day-number:hover {
    color: #fff;
}

.fc .fc-daygrid-day.fc-day-today {
    background: rgba(196, 69, 54, 0.07) !important;
}

.fc-today-highlight {
    background: rgba(196, 69, 54, 0.07) !important;
}

.fc .fc-event {
    border-radius: 6px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    border-width: 0 !important;
    padding: 0.15rem 0.4rem !important;
    cursor: pointer;
}

.fc .fc-event:hover {
    filter: brightness(1.12);
}

.fc .fc-event-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc .fc-daygrid-more-link {
    color: var(--accent-red);
    font-weight: 700;
    font-size: 0.75rem;
}

.fc .fc-timegrid-now-indicator-line {
    border-color: var(--accent-red);
}

.fc .fc-timegrid-now-indicator-arrow {
    border-top-color: var(--accent-red);
    border-bottom-color: var(--accent-red);
}

/* ── Daily agenda ────────────────────────────────────── */
.agenda-section {
    background: var(--dark-card);
    border: 1px solid var(--dark-card-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 3rem;
}

.agenda-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.agenda-title i {
    color: var(--accent-red);
}

#agendaDate {
    color: var(--text-secondary);
}

.agenda-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.agenda-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.agenda-error {
    color: var(--accent-red);
}

.agenda-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.agenda-item {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.agenda-item:hover {
    border-color: rgba(196, 69, 54, 0.25);
}

.agenda-time-bar {
    width: 4px;
    flex-shrink: 0;
}

.agenda-item-content {
    flex: 1;
    padding: 0.75rem 1rem;
    min-width: 0;
}

.agenda-item-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.agenda-time {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.agenda-status-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
}

.agenda-service {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-client {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.agenda-notes {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 0 0.75rem;
}

.agenda-edit-btn,
.agenda-pdf-btn {
    /* inherits .btn-action styles from presupuestos — defined here too */
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.agenda-edit-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(37, 99, 235, 0.4);
    color: #60a5fa;
}

.agenda-pdf-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(196, 69, 54, 0.4);
    color: var(--accent-red);
}

.agenda-pdf-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ── CRM Modal ───────────────────────────────────────── */
.crm-modal {
    background: #111111;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    max-width: 100%;
}

.crm-modal-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 1.25rem 1.5rem;
}

.crm-modal-header .modal-title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

.crm-modal-body {
    padding: 1.5rem;
}

.crm-modal-footer {
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding: 1rem 1.5rem;
    gap: 0.75rem;
    display: flex;
    align-items: center;
}

/* ── Form sections ───────────────────────────────────── */
.crm-form-section {
    margin-bottom: 1.5rem;
}

.crm-form-section-title {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.crm-form-section-title i {
    color: var(--accent-red);
}

/* ── CRM Inputs ──────────────────────────────────────── */
.crm-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.crm-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    font-family: 'Raleway', sans-serif;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}

.crm-input:focus {
    border-color: rgba(196, 69, 54, 0.5);
    background: rgba(255, 255, 255, 0.06);
}

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

.crm-input.is-invalid {
    border-color: rgba(196, 69, 54, 0.7);
}

.crm-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a5a5a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.2rem;
    cursor: pointer;
}

.crm-select option {
    background: #1a1a1a;
    color: #fff;
}

.crm-textarea {
    resize: vertical;
    min-height: 80px;
}

.crm-field-error {
    color: #e07b6e;
    font-size: 0.77rem;
    margin-top: 0.3rem;
    min-height: 1em;
}

/* ── Client search in modal ──────────────────────────── */
.client-search-wrap {
    position: relative;
    margin-bottom: 0.5rem;
}

.client-search-wrap i {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.client-search-wrap .crm-input {
    padding-left: 2.4rem;
}

.client-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.dropdown-item-client {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-item-client:last-child {
    border-bottom: none;
}

.dropdown-item-client:hover {
    background: rgba(196, 69, 54, 0.1);
}

.dropdown-item-client > i {
    margin-top: 2px;
    flex-shrink: 0;
}

.dropdown-client-name {
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.3;
}

.dropdown-client-sub {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 1px;
}

.dropdown-empty {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* ── Selected client chip ────────────────────────────── */
.selected-client-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(196, 69, 54, 0.1);
    border: 1px solid rgba(196, 69, 54, 0.25);
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    margin-top: 0.4rem;
}

.selected-client-chip i {
    color: var(--accent-red);
}

.chip-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    margin-left: auto;
    padding: 0 0.2rem;
    line-height: 1;
    transition: color 0.15s;
}

.chip-remove:hover {
    color: var(--accent-red);
}

/* ── Auth Loader ─────────────────────────────────────── */
#authLoader {
    position: fixed;
    inset: 0;
    background: var(--dark-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

#authLoader.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* ── Datetime wrapper (date + time side by side) ─────── */
.turno-datetime-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.turno-dt-field {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.turno-dt-field--time {
    flex: 0 0 110px;
    width: 110px;
}

.turno-dt-sublabel {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.turno-date-input,
.turno-time-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    .turnos-title {
        font-size: 1.8rem;
    }

    .turnos-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .fc .fc-toolbar-title {
        font-size: 0.95rem;
    }

    .agenda-item-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }

    /* Modal fecha inputs en mobile */
    #turnoModal .modal-dialog {
        margin: 0.75rem !important;
        max-width: calc(100% - 1.5rem) !important;
    }

    .crm-modal-body {
        padding: 1rem;
    }

    .crm-modal-header {
        padding: 1rem;
    }

    .crm-modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }
}
