/* ========================================
   LOGIN.CSS — Login page styles
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    /* En portrait no scrollear; en landscape sí (ver media query) */
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Fix iOS Safari url-bar bug */
    background: #000;
}

.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-image: url('../assets/images/logo.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Safe area: notch (top), home indicator (bottom), iPhone islands (sides) */
    padding: max(20px, env(safe-area-inset-top))
             max(20px, env(safe-area-inset-right))
             max(20px, env(safe-area-inset-bottom))
             max(20px, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.login-screen::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(160deg, rgba(0, 102, 51, 0.92) 0%, rgba(124, 186, 85, 0.88) 100%);
    z-index: -1;
}

.login-container {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 32px 28px;
    /* Extra padding at bottom for home indicator */
    padding-bottom: max(32px, calc(20px + env(safe-area-inset-bottom)));
    max-width: 420px;
    width: 100%;
    margin: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.login-logo {
    max-width: 200px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 15px;
    mix-blend-mode: multiply;
    border-radius: 8px;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    text-align: center;
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    color: white;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 13px 14px;
    padding-left: 42px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    /* 16px mínimo previene el zoom automático en iOS */
    font-size: 16px;
    min-height: 48px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.form-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
}

.form-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

/* Date display inputs — tappable, readonly */
.date-display-input {
    cursor: pointer;
    caret-color: transparent;
    padding-right: 36px;
}

.date-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    pointer-events: none;
    transition: color 0.2s;
}

.date-picker-trigger:hover .date-arrow {
    color: white;
}

.input-icon-svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-icon-svg svg {
    width: 100%;
    height: 100%;
}

/* Name row (nombre + apellidos side by side) */
.name-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Separator between date fields */
.date-separator {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 600;
    margin: 8px 0;
    position: relative;
}

.date-separator::before,
.date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 25px);
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.date-separator::before { left: 0; }
.date-separator::after  { right: 0; }

.login-button {
    width: 100%;
    padding: 15px;
    min-height: 52px;
    background: #006633;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 102, 51, 0.45);
    margin-top: 10px;
    -webkit-tap-highlight-color: transparent;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 51, 0.65);
}

.login-button:active {
    transform: translateY(0);
}

.error-text {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
    display: none;
    line-height: 1.4;
}

.help-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    text-align: center;
    margin-top: 16px;
    line-height: 1.4;
}

.date-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    margin-top: 4px;
    font-style: italic;
}

/* ========== "OLVIDASTE TUS DATOS" LINK ========== */
.forgot-link {
    display: block;
    text-align: center;
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    margin-top: 14px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
    padding: 8px 0; /* Mayor área táctil */
    -webkit-tap-highlight-color: transparent;
}

.forgot-link:hover {
    color: white;
}

/* ================================================
   DATE PICKER — iOS-style scroll wheels
   ================================================ */
.date-picker-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    display: none;
    align-items: flex-end; /* Sube desde abajo en mobile */
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

.date-picker-backdrop.active {
    display: flex;
    opacity: 1;
}

/* En pantallas grandes centramos el picker */
@media (min-width: 480px) {
    .date-picker-backdrop {
        align-items: center;
    }
}

.date-picker-sheet {
    width: calc(100% - 24px);
    max-width: 420px;
    background: rgba(0, 66, 33, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 22px;
    /* Safe area at bottom for home indicator */
    padding: 0 0 max(20px, env(safe-area-inset-bottom));
    transform: translateY(30px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.date-picker-backdrop.active .date-picker-sheet {
    transform: translateY(0);
    opacity: 1;
}

/* Header bar */
.date-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dp-title {
    color: white;
    font-size: 16px;
    font-weight: 700;
}

.dp-cancel,
.dp-confirm {
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    min-height: 44px;
    border-radius: 8px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.dp-cancel { color: rgba(255, 255, 255, 0.6); }
.dp-cancel:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.dp-confirm { color: #7cba55; }
.dp-confirm:hover {
    background: rgba(124, 186, 85, 0.15);
}

/* Wheel area */
.date-picker-wheels {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 10px 16px;
    position: relative;
    overflow: hidden;
}

.wheel-column {
    flex: 1;
    max-width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wheel-label {
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    line-height: 16px;
    height: 16px;
}

/* Scroll container */
.wheel-scroll {
    height: 180px;
    overflow-y: auto;
    width: 100%;
    position: relative;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(to bottom,
        transparent 0%, black 30%, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom,
        transparent 0%, black 30%, black 70%, transparent 100%);
}

.wheel-scroll::-webkit-scrollbar { display: none; }

/* Individual items */
.wheel-item {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.35);
    font-size: 17px;
    font-weight: 500;
    scroll-snap-align: center;
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
    border-radius: 10px;
}

.wheel-item.selected {
    color: white;
    font-size: 20px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
}

/* Wheel highlight bar */
.wheel-highlight {
    position: absolute;
    left: 16px;
    right: 16px;
    top: 100px;
    height: 44px;
    background: rgba(124, 186, 85, 0.15);
    border-radius: 12px;
    border: 1px solid rgba(124, 186, 85, 0.30);
    pointer-events: none;
    z-index: 0;
}

/* ========== SEARCH MODAL ========== */
.search-modal-backdrop {
    position: fixed;
    top: var(--search-modal-top, 0px);
    left: 0;
    width: 100%;
    height: var(--search-modal-height, 100dvh);
    min-height: var(--search-modal-height, 100dvh);
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding:
        max(12px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        max(12px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
    opacity: 0;
    transition: opacity 0.3s ease, top 0.25s ease, height 0.25s ease;
}

.search-modal-backdrop.active {
    display: flex;
    opacity: 1;
}

@media (min-width: 540px) {
    .search-modal-backdrop {
        padding: 20px;
    }
}

.search-modal {
    background: rgba(0, 66, 33, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 20px;
    padding: 22px 18px;
    padding-bottom: max(22px, calc(16px + env(safe-area-inset-bottom)));
    max-width: 560px;
    width: 100%;
    max-height: min(88dvh, calc(var(--search-modal-height, 100dvh) - 24px));
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transform: translateY(12px);
    transition: transform 0.25s ease;
    overflow: hidden;
}

@media (min-width: 540px) {
    .search-modal {
        padding-bottom: 22px;
        max-height: 80vh;
    }
}

.search-modal-backdrop.active .search-modal {
    transform: translateY(0);
}

.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.search-modal-title {
    color: white;
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
}

.search-controls-row {
    display: grid;
    grid-template-columns: minmax(0, 2.25fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.search-modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.search-modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.search-input-wrapper {
    position: relative;
    margin-bottom: 12px;
    min-width: 0;
}

.search-filter-wrapper { margin-bottom: 0; }
.search-main-wrapper   { margin-bottom: 0; }

.search-input {
    width: 100%;
    padding: 13px 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px; /* 16px mínimo en iOS para evitar zoom */
    min-height: 48px;
    box-sizing: border-box;
    transition: border-color 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.search-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
    font-size: 14px;
}

#garden-filter-select {
    padding-right: 34px;
}

.search-select {
    appearance: none;
    -webkit-appearance: none;
    border-color: rgba(124, 186, 85, 0.45);
    background: linear-gradient(160deg, rgba(0, 102, 51, 0.58) 0%, rgba(16, 88, 47, 0.7) 100%);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #f2fff7;
}

.search-filter-wrapper::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 47%;
    width: 7px;
    height: 7px;
    border-right: 2px solid rgba(240, 255, 247, 0.82);
    border-bottom: 2px solid rgba(240, 255, 247, 0.82);
    transform: translateY(-50%) rotate(45deg);
    pointer-events: none;
}

.search-select option {
    background: #0a4b2c;
    color: #f3fff7;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 80px;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}

.search-result-item {
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(0, 102, 51, 0.55);
    transform: translateX(3px);
}

.search-result-item:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.99);
}

.search-result-name {
    color: white;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.search-result-details {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    line-height: 1.6;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.search-result-details span {
    display: inline-flex;
    align-items: center;
    white-space: normal;
    word-break: break-word;
}

.search-result-details .item-icon { opacity: 0.7; flex-shrink: 0; }

.search-result-details .search-location-field {
    width: 100%;
    align-items: flex-start;
}

.search-result-details .search-location-field .item-icon {
    margin-top: 2px;
}

.search-no-results {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 30px 10px;
    font-size: 14px;
}

.search-hint {
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    text-align: center;
    margin-top: 10px;
}

/* ========== RESPONSIVE ========== */

/* Pantallas pequeñas (iPhone SE, Galaxy A < 390px) */
@media (max-width: 389px) {
    .login-screen {
        padding: max(16px, env(safe-area-inset-top))
                 max(12px, env(safe-area-inset-right))
                 max(16px, env(safe-area-inset-bottom))
                 max(12px, env(safe-area-inset-left));
    }

    .login-container {
        padding: 22px 16px;
        padding-bottom: max(22px, calc(16px + env(safe-area-inset-bottom)));
        border-radius: 20px;
    }

    .name-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .login-logo {
        max-width: 150px;
        margin-bottom: 10px;
    }

    .login-subtitle {
        font-size: 13px;
        margin-bottom: 18px;
    }

    .login-button {
        font-size: 15px;
        padding: 13px;
    }

    .search-controls-row {
        grid-template-columns: 1fr;
    }
}

/* Pantallas medianas (390px–767px) — mayoría de smartphones */
@media (min-width: 390px) and (max-width: 767px) {
    .login-container {
        padding: 28px 24px;
        padding-bottom: max(28px, calc(20px + env(safe-area-inset-bottom)));
    }
}

/* Tablets y pantallas grandes (≥ 768px) */
@media (min-width: 768px) {
    .login-container {
        padding: 40px 40px;
    }

    .login-logo {
        max-width: 220px;
    }

    .form-input {
        font-size: 16px;
        padding: 14px 16px 14px 46px;
    }

    .login-button {
        font-size: 18px;
        padding: 17px;
    }

    .search-modal {
        border-radius: 20px;
        max-height: 75vh;
    }
}

/* Landscape en phones — permitir scroll y ajustar alturas */
@media (orientation: landscape) and (max-height: 600px) {
    body {
        overflow-y: auto;
    }

    .login-screen {
        position: relative;
        height: auto;
        min-height: 100dvh;
        align-items: flex-start;
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .login-container {
        margin: auto;
        max-height: none;
        padding: 20px 24px;
        padding-bottom: max(20px, calc(12px + env(safe-area-inset-bottom)));
    }

    .login-logo {
        max-width: 120px;
        margin-bottom: 10px;
    }

    .login-subtitle {
        font-size: 13px;
        margin-bottom: 14px;
    }

    .form-group {
        margin-bottom: 10px;
    }

    .name-row {
        grid-template-columns: 1fr 1fr;
    }

    .date-separator {
        margin: 4px 0;
    }

    .login-button {
        padding: 12px;
        margin-top: 6px;
    }

    .date-picker-sheet {
        width: calc(100% - 24px);
        max-width: 500px;
    }

    .wheel-scroll {
        height: 140px;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-10px); }
    75%       { transform: translateX(10px); }
}
