:root {
    --green: #16a34a;
    --green-dark: #0f7d49;
    --red: #dc3545;
    --blue: #9d5c80;
    --blue-dark: #7f3d63;
    --orange: #f59e0b;
    --purple: #b04d7d;
    --dark: #352238;
    --bg: linear-gradient(135deg, #fdf2f8 0%, #f7edf3 45%, #f5f7fb 100%);
    --card: rgba(255, 255, 255, .94);
    --muted: #806f80;
    --border: #ead8e6;
    --soft-green: #ecfdf5;
    --soft-orange: #fff7ed;
    --soft-blue: #fce7f3;
    --soft-pink: #fff1f7;
    --pink: #d65d8e;
    --pink-dark: #a83f6b;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--dark);
    min-height: 100vh;
}
.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 14px 48px;
}
.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.top-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
h1, h2, h3 { margin-top: 0; }
.card {
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 22px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 14px 35px rgba(157, 92, 128, .10);
}
.nav-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.nav-tabs a {
    display: block;
    text-decoration: none;
    text-align: center;
    padding: 14px 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--dark);
    font-weight: 800;
}
.nav-tabs a.active {
    background: linear-gradient(135deg, var(--pink), var(--blue));
    color: #fff;
    border-color: transparent;
}
label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}
input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: #fff;
    font-family: Arial, Helvetica, sans-serif;
}
textarea { min-height: 86px; resize: vertical; }
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: end;
}
.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: end;
}
.grid3 {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 12px;
    align-items: end;
}
.time-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: 14px;
}
.btn-primary { background: linear-gradient(135deg, var(--pink), var(--blue)); color: #fff; box-shadow: 0 8px 18px rgba(157,92,128,.22); }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-purple { background: linear-gradient(135deg, var(--purple), var(--pink)); color: #fff; }
.btn-light { background: #fff1f7; color: #8a315c; }
.btn-gray { background: #e5e7eb; color: #111827; }
.muted { color: var(--muted); }
.notice {
    background: var(--soft-orange);
    border: 1px solid #fde68a;
    color: #7c4a03;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 14px;
    line-height: 1.45;
}
.success-note {
    background: var(--soft-green);
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 14px;
    line-height: 1.45;
}
.info-note {
    background: #fff1f7;
    border: 1px solid #f5c6da;
    color: #7f3d63;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 14px;
    line-height: 1.45;
}
.slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 12px;
}
.slot {
    border-radius: 16px;
    padding: 13px;
    color: #fff;
}
.slot.available { background: var(--green); }
.slot.occupied { background: var(--red); }
.slot strong { display: block; font-size: 18px; }
.slot small { display: block; margin-top: 3px; opacity: .92; }
.slot-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}
.slot-actions form { flex: 1; }
.slot-actions .btn {
    width: 100%;
    padding: 9px 8px;
    font-size: 12px;
}
table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}
th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th { background: #f9fafb; }
.total {
    font-size: 26px;
    font-weight: 800;
    color: var(--green);
}
.summary-boxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.summary-boxes-4 {
    grid-template-columns: repeat(4, 1fr);
}
.summary-boxes-5 {
    grid-template-columns: repeat(5, 1fr);
}
.summary-boxes-6 {
    grid-template-columns: repeat(3, 1fr);
}
.summary {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}
.summary span {
    color: var(--muted);
    font-size: 13px;
}
.summary strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
    line-height: 1.1;
}
.login {
    max-width: 430px;
    margin: 90px auto;
}
.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}
.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 800;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-wait { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.actions form { display: inline; }
code {
    background: #f3f4f6;
    padding: 2px 5px;
    border-radius: 6px;
}
@media (max-width: 900px) {
    .summary-boxes-4, .summary-boxes-5, .summary-boxes-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 760px) {
    .grid, .grid2, .grid3, .summary-boxes, .summary-boxes-4, .summary-boxes-5, .summary-boxes-6, .nav-tabs {
        grid-template-columns: 1fr;
    }
    .top { display: block; }
    .top-actions { margin-top: 12px; }
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tr {
        border: 1px solid var(--border);
        border-radius: 14px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    td {
        border-bottom: 1px solid var(--border);
    }
    .actions .btn { width: 100%; }
}

.slot.service-notice {
    background: linear-gradient(135deg, var(--orange), #d97706);
}
.slot-actions-stack {
    display: block;
}
.slot-actions-stack form {
    width: 100%;
    margin-top: 6px;
}
.slot-actions-stack .service-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.slot-actions-stack select {
    padding: 8px;
    border-radius: 10px;
    font-size: 12px;
}
.slot-actions-stack .btn {
    width: 100%;
}
.status-button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}
.status-button-row form {
    margin-top: 0;
}
.return-actions {
    margin-top: 8px;
}
.return-actions span {
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 5px;
    opacity: .95;
}
.return-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}
.return-grid form {
    margin-top: 0;
}
.return-grid .btn {
    padding: 8px 4px;
    font-size: 10px;
}

/* Agrupacion de horarios por fecha en el panel admin */
.day-groups {
    display: grid;
    gap: 18px;
}
.day-group-card {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
}
.day-group-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.day-group-header h3 {
    margin: 2px 0 0;
    font-size: 20px;
    line-height: 1.25;
}
.day-kicker {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--blue);
    background: var(--soft-blue);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 5px 8px;
}
.day-summary {
    min-width: 150px;
    text-align: right;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}
.day-summary span {
    display: block;
    font-weight: 800;
    color: var(--dark);
}
.day-summary small {
    display: block;
    margin-top: 3px;
}
.slots-grouped {
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.slots-grouped .slot {
    min-height: 146px;
}
.slots-grouped .slot strong {
    font-size: 20px;
}

@media (max-width: 760px) {
    .day-group-header {
        display: block;
    }
    .day-summary {
        text-align: left;
        margin-top: 8px;
    }
    .slots-grouped {
        grid-template-columns: 1fr;
    }
}

/* Dias sin trabajo */
.no-work-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}
.closed-day-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 14px;
    padding: 12px;
}
.closed-day-row strong {
    display: block;
    color: #7c2d12;
    margin-bottom: 4px;
}
.closed-day-row small {
    display: block;
    color: #9a3412;
    line-height: 1.35;
}
.closed-day-row form {
    flex: 0 0 auto;
}
.closed-warning {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 12px;
    line-height: 1.4;
}
.day-group-card.day-group-closed {
    background: #fffbeb;
    border-color: #fbbf24;
}
.day-group-card.day-group-closed .day-kicker {
    color: #92400e;
    background: #fef3c7;
    border-color: #fde68a;
}
@media (max-width: 760px) {
    .closed-day-row {
        display: block;
    }
    .closed-day-row form {
        margin-top: 10px;
    }
    .closed-day-row .btn {
        width: 100%;
    }
}


/* Contador de visitas */
.visitas-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}
.visitas-head h2 {
    margin-bottom: 6px;
}
.visitas-head p {
    margin: 0;
}
.visitas-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.visitas-mini span {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    color: var(--muted);
}
.visitas-mini strong {
    color: var(--dark);
}
@media (max-width: 760px) {
    .visitas-head {
        display: block;
    }
    .visitas-head .btn {
        width: 100%;
        margin-top: 10px;
    }
}

/* Panel admin mas practico: acciones desplegables */
.compact-note {
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.35;
}
.compact-intro {
    margin: -4px 0 12px;
    font-size: 13px;
}
.quick-actions-card {
    padding-bottom: 14px;
}
.toggle-actions {
    display: grid;
    gap: 10px;
}
.admin-toggle-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(17, 24, 39, .035);
}
.admin-toggle-card summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    font-weight: 800;
    color: var(--dark);
    user-select: none;
}
.admin-toggle-card summary::-webkit-details-marker {
    display: none;
}
.admin-toggle-card summary span {
    display: block;
    font-size: 15px;
}
.admin-toggle-card summary small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
}
.admin-toggle-card summary::after {
    content: '+';
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: var(--soft-blue);
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
}
.admin-toggle-card[open] summary {
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
}
.admin-toggle-card[open] summary::after {
    content: '−';
    background: #fff7ed;
    color: #c2410c;
}
.toggle-content {
    padding: 14px 16px 16px;
}
.range-extra-grid {
    margin-top: 12px;
}
.range-message-field {
    grid-column: span 2;
}
.compact-list {
    margin-top: 12px;
}
.compact-list .closed-day-row {
    padding: 10px;
}
.compact-list .closed-day-row small {
    font-size: 12px;
}
.quick-actions-card textarea {
    min-height: 70px;
}

@media (max-width: 760px) {
    .card {
        padding: 14px;
        border-radius: 16px;
        margin-bottom: 12px;
    }
    .card h2 {
        font-size: 19px;
        margin-bottom: 10px;
    }
    .admin-toggle-card summary {
        padding: 13px 12px;
    }
    .toggle-content {
        padding: 12px;
    }
    .range-message-field {
        grid-column: auto;
    }
    .time-row {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }
    input, select, textarea {
        padding: 11px;
        font-size: 14px;
    }
    .btn {
        width: 100%;
    }
}



/* Estilo premium femenino RedHogar */
.top {
    background: rgba(255,255,255,.45);
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 22px;
    padding: 16px 18px;
    box-shadow: 0 10px 28px rgba(157,92,128,.08);
}
.top h1 {
    margin-bottom: 6px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.05;
    background: linear-gradient(90deg, #c2417a, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nav-tabs a {
    background: rgba(255,255,255,.82);
    border-color: #ead8e6;
    box-shadow: 0 8px 18px rgba(157,92,128,.06);
}
.nav-tabs a:hover {
    border-color: #e9a8c4;
    background: #fff7fb;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #d65d8e;
    box-shadow: 0 0 0 4px rgba(214,93,142,.12);
}
button, .btn, .nav-tabs a {
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover, .nav-tabs a:hover {
    transform: translateY(-1px);
}
.summary {
    background: rgba(255,255,255,.86);
    border-color: #ead8e6;
    box-shadow: 0 8px 20px rgba(157,92,128,.06);
}
.day-group-card {
    background: rgba(255,248,252,.78);
    border-color: #ead8e6;
}
.day-kicker {
    color: #a83f6b;
    background: #fff1f7;
    border-color: #f5c6da;
}
th {
    background: #fff1f7;
    color: #5a2b48;
}
.badge-ok, .success-note {
    box-shadow: 0 6px 16px rgba(22,101,52,.06);
}
.admin-toggle-card {
    background: rgba(255,255,255,.88);
    border-color: #ead8e6;
}
.admin-toggle-card summary::after {
    background: #fff1f7;
    color: #c2417a;
}
.admin-toggle-card[open] summary {
    background: #fff7fb;
}
.admin-toggle-card[open] summary::after {
    background: #fce7f3;
    color: #9d174d;
}
@media (max-width: 760px) {
    .wrap { padding: 14px 10px 42px; }
    .top { padding: 14px; }
    .nav-tabs { gap: 8px; }
    .nav-tabs a { padding: 12px 10px; border-radius: 14px; }
}


/* Galería de trabajos */
.gallery-upload-card .grid2 {
    align-items: end;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}
.gallery-item {
    background: rgba(255,255,255,.9);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(157,92,128,.08);
}
.gallery-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    background: #fff1f7;
}
.gallery-body {
    padding: 12px;
}
.gallery-title {
    margin: 0 0 6px;
    font-weight: 800;
    color: var(--dark);
}
.gallery-date {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
}
.gallery-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.gallery-actions form { margin: 0; }
.gallery-empty {
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 18px;
    padding: 28px;
    background: rgba(255,255,255,.65);
}
.public-gallery-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
}
@media (max-width: 760px) {
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .gallery-body { padding: 10px; }
    .gallery-actions { grid-template-columns: 1fr; }
    .public-gallery-header { display: block; }
    .public-gallery-header .btn { margin-top: 10px; }
}


/* Corrección: mantener visible el título de fecha de cada grupo */
.day-title-block {
    flex: 1 1 auto;
    min-width: 0;
}
.day-title-text {
    display: block !important;
    margin: 6px 0 0 !important;
    min-height: 26px;
    color: #2b1730 !important;
    font-weight: 900;
    line-height: 1.25;
}
.day-summary {
    flex: 0 0 auto;
}
@media (max-width: 760px) {
    .day-title-text {
        min-height: auto;
        font-size: 17px;
    }
}


/* Corrección fuerte v2: el título de fecha no depende del h3 ni de estilos anteriores */
.day-title-text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin-top: 6px !important;
    min-height: 26px !important;
    color: #2b1730 !important;
    font-size: 20px !important;
    line-height: 1.25 !important;
    font-weight: 900 !important;
    text-indent: 0 !important;
    white-space: normal !important;
}


/* Parche V3: muestra siempre el título del día, incluso si quedó vacío por caché o datos antiguos */
.day-title-block {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}
.day-title-text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 6px 0 0 !important;
    min-height: 26px !important;
    color: #2b1730 !important;
    font-size: 20px !important;
    line-height: 1.25 !important;
    font-weight: 900 !important;
    text-indent: 0 !important;
    white-space: normal !important;
}
.day-title-text:empty::after {
    content: attr(data-fallback-title);
}

/* Mejora: publicar disponibilidad por rango */
.available-range-extra-grid {
    margin-top: 12px;
}
.available-range-help {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 14px;
    padding: 12px;
    line-height: 1.4;
    font-size: 13px;
    font-weight: 700;
}
.available-range-grid label,
.available-range-extra-grid label {
    color: #243b2d;
}
@media (max-width: 760px) {
    .available-range-help {
        font-size: 12px;
    }
}


/* Botón para borrar todos los horarios de un día */
.delete-day-form {
    margin-top: 8px;
}
.delete-day-form .btn-delete-day {
    width: 100%;
    background: #fff1f7;
    color: #9f1239;
    border: 1px solid #fecdd3;
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 999px;
    box-shadow: none;
}
.delete-day-form .btn-delete-day:hover {
    background: #ffe4e6;
}
@media (max-width: 760px) {
    .delete-day-form .btn-delete-day {
        max-width: 180px;
    }
}

/* Diagnostico y control de alarma Gmail */
.email-help-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #7c2d12;
    border-radius: 14px;
    padding: 12px 14px;
    margin: 12px 0 16px;
    line-height: 1.45;
    font-size: 13px;
}
.inline-form {
    display: inline-block;
    margin: 0;
}
.mt8 {
    margin-top: 8px;
}
.actions form {
    margin: 0;
}
.actions .btn-orange {
    background: #f59e0b;
    color: #fff;
}
@media (max-width: 760px) {
    .email-help-box {
        font-size: 12px;
    }
    .actions .btn {
        width: 100%;
        text-align: center;
    }
}
