/**
 * Comidas Para Todos - Grid & App Styles
 * Archivo: assets/css/grid.css
 * Versión: 1.0.4
 *
 * Estilos para la pantalla principal tipo app:
 * grid de tiles + selector de ubicación + resultados.
 */

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
    --cpt-radius   : 16px;
    --cpt-radius-sm: 10px;
    --cpt-shadow   : 0 4px 16px rgba(0,0,0,.12);
    --cpt-shadow-sm: 0 2px 8px rgba(0,0,0,.08);
    --cpt-font     : -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --cpt-dark     : #1a1a2e;
    --cpt-grey     : #6b7280;
    --cpt-light    : #f8fafc;
    --cpt-white    : #ffffff;
    --cpt-green    : #3BCEAC;
    --cpt-orange   : #FF8C42;
    --cpt-transition: 0.25s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   CONTENEDOR APP
   ============================================================ */
.cpt-app {
    max-width: 480px;
    margin: 0 auto;
    font-family: var(--cpt-font);
    background: var(--cpt-light);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
.cpt-app-header {
    background: var(--cpt-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cpt-shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.cpt-app-header__logo {
    max-height: 40px;
    width: auto;
}

.cpt-app-header__title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--cpt-dark);
    letter-spacing: -.3px;
}

/* ============================================================
   SISTEMA DE PANTALLAS (transiciones)
   ============================================================ */
.cpt-screen {
    display: none;
    padding: 20px;
    min-height: calc(100vh - 72px);
    animation: cpt-fadein var(--cpt-transition);
}

.cpt-screen--active {
    display: block;
}

@keyframes cpt-fadein {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   GRID DE TILES
   ============================================================ */
.cpt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 4px 0;
}

/* 3 columnas si se pide */
.cpt-grid[data-cols="3"] {
    grid-template-columns: repeat(3, 1fr);
}

/* Tile individual */
.cpt-tile {
    position: relative;
    border-radius: var(--cpt-radius);
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none !important;
    cursor: pointer;
    transition: transform var(--cpt-transition), box-shadow var(--cpt-transition);
    box-shadow: var(--cpt-shadow);
    min-height: 110px;
    overflow: hidden;
}

/* Efecto brillo sutil en la esquina superior */
.cpt-tile::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 70%;
    height: 70%;
    background: rgba(255,255,255,.18);
    border-radius: 50%;
    pointer-events: none;
}

.cpt-tile:hover,
.cpt-tile:focus {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    outline: none;
}

.cpt-tile:active {
    transform: scale(.97);
}

.cpt-tile__icon {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
}

.cpt-tile__label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--cpt-white);
    text-align: center;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,.2);
    letter-spacing: .2px;
}

/* Tile vacío / mensaje de configuración */
.cpt-grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    background: var(--cpt-white);
    border-radius: var(--cpt-radius);
    color: var(--cpt-grey);
    font-size: .95rem;
    line-height: 1.6;
}

/* ============================================================
   BOTÓN VOLVER
   ============================================================ */
.cpt-back-btn {
    background: none;
    border: none;
    color: var(--cpt-green);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--cpt-font);
}

.cpt-back-btn:hover {
    color: var(--cpt-dark);
}

/* ============================================================
   PANTALLA DE UBICACIÓN
   ============================================================ */
.cpt-location-box {
    background: var(--cpt-white);
    border-radius: var(--cpt-radius);
    padding: 28px 24px;
    box-shadow: var(--cpt-shadow);
}

.cpt-location-category {
    display: inline-block;
    background: var(--cpt-green);
    color: var(--cpt-white);
    font-size: .8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.cpt-location-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cpt-dark);
    margin: 0 0 24px 0;
    line-height: 1.2;
}

/* Botón geolocalizar */
.cpt-geo-btn {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--cpt-green);
    background: #f0fdf9;
    border-radius: var(--cpt-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--cpt-font);
    transition: all var(--cpt-transition);
    margin-bottom: 8px;
}

.cpt-geo-btn:hover {
    background: var(--cpt-green);
}

.cpt-geo-btn:hover .cpt-geo-btn__text {
    color: var(--cpt-white);
}

.cpt-geo-btn__icon {
    font-size: 1.4rem;
}

.cpt-geo-btn__text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cpt-green);
    transition: color var(--cpt-transition);
}

/* Estado del GPS */
.cpt-geo-status {
    text-align: center;
    font-size: .85rem;
    color: var(--cpt-grey);
    min-height: 20px;
    margin-bottom: 8px;
}

/* Divisor "o" */
.cpt-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--cpt-grey);
    font-size: .85rem;
}

.cpt-divider::before,
.cpt-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

/* Buscador de ciudad */
.cpt-city-search {
    position: relative;
    margin-bottom: 20px;
}

.cpt-city-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: var(--cpt-radius-sm);
    font-size: 1rem;
    font-family: var(--cpt-font);
    transition: border-color var(--cpt-transition);
    box-sizing: border-box;
    background: var(--cpt-white);
}

.cpt-city-input:focus {
    outline: none;
    border-color: var(--cpt-green);
    box-shadow: 0 0 0 3px rgba(59,206,172,.12);
}

/* Sugerencias autocomplete */
.cpt-city-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--cpt-white);
    border: 1px solid #e5e7eb;
    border-radius: var(--cpt-radius-sm);
    box-shadow: var(--cpt-shadow);
    z-index: 200;
    overflow: hidden;
    display: none;
}

.cpt-city-suggestions.cpt-visible {
    display: block;
}

.cpt-suggestion {
    padding: 12px 16px;
    cursor: pointer;
    font-size: .95rem;
    color: var(--cpt-dark);
    transition: background var(--cpt-transition);
    border-bottom: 1px solid #f3f4f6;
}

.cpt-suggestion:last-child {
    border-bottom: none;
}

.cpt-suggestion:hover,
.cpt-suggestion.cpt-selected {
    background: #f0fdf9;
    color: var(--cpt-green);
}

.cpt-suggestion__province {
    font-size: .8rem;
    color: var(--cpt-grey);
}

/* Botón buscar */
.cpt-search-btn {
    width: 100%;
    padding: 16px;
    background: var(--cpt-green);
    color: var(--cpt-white);
    border: none;
    border-radius: var(--cpt-radius-sm);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--cpt-font);
    cursor: pointer;
    transition: all var(--cpt-transition);
    letter-spacing: .3px;
}

.cpt-search-btn:hover:not(:disabled) {
    background: #2db89a;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59,206,172,.35);
}

.cpt-search-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ============================================================
   PANTALLA DE RESULTADOS
   ============================================================ */
.cpt-results-header {
    margin-bottom: 16px;
}

.cpt-results-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cpt-dark);
    margin: 0;
}

.cpt-results-subtitle {
    font-size: .85rem;
    color: var(--cpt-grey);
    margin: 4px 0 0;
}

.cpt-results-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Tarjeta de resultado */
.cpt-result-card {
    background: var(--cpt-white);
    border-radius: var(--cpt-radius);
    padding: 18px;
    box-shadow: var(--cpt-shadow-sm);
    border-left: 4px solid var(--cpt-green);
    transition: transform var(--cpt-transition), box-shadow var(--cpt-transition);
}

.cpt-result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cpt-shadow);
}

.cpt-result-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.cpt-result-card__name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cpt-dark);
    margin: 0;
    line-height: 1.3;
}

.cpt-result-card__rating {
    background: #fef3c7;
    color: #92400e;
    font-weight: 700;
    font-size: .8rem;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.cpt-result-card__address {
    font-size: .85rem;
    color: var(--cpt-grey);
    margin-bottom: 10px;
    padding-left: 18px;
    position: relative;
}

.cpt-result-card__address::before {
    content: '📍';
    position: absolute;
    left: 0;
    font-size: .75rem;
}

.cpt-result-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.cpt-tag {
    font-size: .75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    color: var(--cpt-white);
}

.cpt-result-card__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cpt-btn-action {
    flex: 1;
    min-width: 90px;
    padding: 9px 12px;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    font-size: .82rem;
    font-weight: 600;
    transition: all var(--cpt-transition);
    font-family: var(--cpt-font);
    cursor: pointer;
    border: none;
}

.cpt-btn-action--phone   { background: #dcfce7; color: #15803d; }
.cpt-btn-action--maps    { background: #dbeafe; color: #1d4ed8; }
.cpt-btn-action--web     { background: #fff7ed; color: #c2410c; }

.cpt-btn-action:hover    { filter: brightness(.93); transform: translateY(-1px); }

/* Loading */
.cpt-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--cpt-grey);
    font-size: .95rem;
}

.cpt-loading::after {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--cpt-green);
    border-radius: 50%;
    margin: 14px auto 0;
    animation: cpt-spin .7s linear infinite;
}

@keyframes cpt-spin {
    to { transform: rotate(360deg); }
}

/* Sin resultados */
.cpt-no-results {
    text-align: center;
    padding: 50px 20px;
    background: var(--cpt-white);
    border-radius: var(--cpt-radius);
}

.cpt-no-results__icon { font-size: 2.5rem; margin-bottom: 12px; }
.cpt-no-results__text { color: var(--cpt-grey); font-size: .95rem; line-height: 1.6; }

/* ============================================================
   RESPONSIVE — pantallas muy pequeñas
   ============================================================ */
@media (max-width: 360px) {
    .cpt-tile {
        min-height: 90px;
        padding: 16px 10px;
    }
    .cpt-tile__icon  { font-size: 1.6rem; }
    .cpt-tile__label { font-size: .78rem; }
}

/* En desktop, centrar y limitar ancho como una app */
@media (min-width: 520px) {
    .cpt-app {
        border-radius: 24px;
        margin: 20px auto;
        box-shadow: 0 8px 40px rgba(0,0,0,.12);
        min-height: auto;
    }
}
