/* ========================================
   GreenQuart - Estilos principales
   Mobile-first responsive design
   ======================================== */

:root {
    --verde-principal: #7E8F6B;
    --verde-hover: #6a7c59;
    --verde-claro: #e8ede3;
    --verde-boton: #6BAF92;
    --verde-boton-hover: #5a9f84;
    --blanco: #ffffff;
    --fondo: #f4f6f8;
    --texto: #333333;
    --texto-light: #666666;
    --sombra: rgba(0, 0, 0, 0.1);
    --sombra-fuerte: rgba(0, 0, 0, 0.15);
    --radio: 12px;
    --radio-sm: 8px;
    color-scheme: light;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--verde-boton);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== CARD COMUN (login, registro, verificar) ===== */
.page-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.card-auth {
    background: var(--blanco);
    padding: 40px 32px;
    border-radius: var(--radio);
    box-shadow: 0 10px 30px var(--sombra);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.card-auth .logo {
    max-width: 180px;
    margin: 0 auto 8px;
}

.card-auth .subtitulo {
    color: var(--texto-light);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* ===== FORMULARIOS ===== */
.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: flex;
    gap: 10px;
}

input, select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: var(--radio-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background: var(--blanco);
}

select {
    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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--verde-boton);
    box-shadow: 0 0 0 3px rgba(107, 175, 146, 0.15);
}

input[type="password"] {
    letter-spacing: 2px;
}

.input-code {
    text-align: center;
    letter-spacing: 6px;
    font-size: 1.3rem;
    font-weight: bold;
}

/* ===== BOTONES ===== */
.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radio-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--verde-boton);
    color: var(--blanco);
}

.btn-primary:hover {
    background: var(--verde-boton-hover);
    text-decoration: none;
}

.btn-vote {
    width: auto;
    padding: 10px 20px;
    margin: 4px;
    font-size: 0.9rem;
}

/* ===== MENSAJES ===== */
.msg {
    padding: 10px 16px;
    border-radius: var(--radio-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 500;
}

.msg-error {
    background: #ffeaea;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.msg-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.msg-logout {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
    transition: opacity 0.5s;
}

/* ===== LINKS ===== */
.links {
    margin-top: 18px;
    font-size: 0.9rem;
}

.links a {
    color: var(--verde-boton);
}

/* ===== PREVIEW VIVIENDA ===== */
.preview-vivienda {
    margin: 8px 0 16px;
    font-weight: bold;
    color: var(--verde-principal);
    font-size: 1.05rem;
    min-height: 1.4em;
}

/* ========================================
   HOME - TOPBAR
   ======================================== */
.topbar {
    background: var(--blanco);
    padding: 16px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    position: relative;
    min-height: 80px;
}

.topbar .logo-topbar {
    width: 120px;
    flex-shrink: 0;
}

.topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: var(--verde-principal);
}

.topbar-center .titulo {
    font-size: 1.3rem;
    letter-spacing: 5px;
    font-weight: bold;
}

.topbar-center .subtitulo-top {
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-top: 2px;
}

.topbar-center .area-privada {
    font-size: 0.75rem;
    letter-spacing: 1px;
    margin-top: 4px;
}

.topbar-center .vivienda-info {
    font-size: 0.72rem;
    font-weight: bold;
    color: var(--blanco);
    margin-top: 3px;
    background: var(--verde-principal);
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
}

.topbar-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-config {
    background: var(--verde-claro);
    color: var(--verde-principal);
    padding: 8px 16px;
    border-radius: var(--radio-sm);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-config:hover {
    background: #d4dcc9;
    text-decoration: none;
}

.btn-logout {
    background: var(--verde-principal);
    color: var(--blanco);
    padding: 8px 16px;
    border-radius: var(--radio-sm);
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: var(--verde-hover);
    text-decoration: none;
}

/* ========================================
   HOME - MENU
   ======================================== */
.menu {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 22px 30px;
    background: var(--verde-principal);
    flex-wrap: wrap;
}

.menu-card {
    background: var(--blanco);
    padding: 22px 20px;
    border-radius: var(--radio);
    cursor: pointer;
    font-weight: 700;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    color: var(--verde-principal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 150px;
}

.menu-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    text-decoration: none;
}

.menu-icon {
    font-size: 2.4rem;
    line-height: 1;
}

.menu-label {
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.menu-disabled {
    opacity: 0.45;
    cursor: default;
}

.menu-disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ========================================
   HOME - GALERIA
   ======================================== */
.galeria {
    padding: 14px 20px 8px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.galeria h2 {
    color: var(--verde-principal);
    margin-bottom: 16px;
    font-size: 1.3rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    position: relative;
    display: inline-block;
}

.galeria h2::before,
.galeria h2::after {
    content: '';
    display: inline-block;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--verde-principal));
    vertical-align: middle;
    margin: 0 14px;
}

.galeria h2::after {
    background: linear-gradient(90deg, var(--verde-principal), transparent);
}

.slider {
    overflow: hidden;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.slider-track {
    display: flex;
    gap: 20px;
    height: 100%;
}

.slide {
    border-radius: var(--radio);
    border: 3px solid var(--verde-principal);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blanco);
    padding: 0;
    cursor: grab;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.slide img {
    height: 100%;
    width: auto;
    max-width: none;
    object-fit: cover;
    border-radius: 9px;
}

.controls {
    position: relative;
    margin-top: 12px;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}

.btn-slider {
    padding: 10px 14px;
    border: none;
    background: var(--verde-principal);
    color: var(--blanco);
    border-radius: var(--radio);
    cursor: pointer;
    font-size: 1.4rem;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}

.btn-slider:hover {
    background: var(--verde-hover);
    transform: scale(1.08);
}

/* ===== MODAL IMAGEN ===== */
.modal-img {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    cursor: pointer;
}

.modal-img img {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

/* ========================================
   VOTACIONES
   ======================================== */
.page-header {
    background: var(--verde-principal);
    color: var(--blanco);
    padding: 18px 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.3rem;
    letter-spacing: 1px;
}

.btn-back {
    color: var(--blanco);
    font-size: 0.85rem;
    padding: 6px 14px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radio-sm);
    transition: border-color 0.2s;
}

.btn-back:hover {
    border-color: var(--blanco);
    text-decoration: none;
}

.container {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.card-propuesta {
    background: var(--blanco);
    padding: 24px;
    border-radius: var(--radio);
    margin-bottom: 16px;
    box-shadow: 0 4px 15px var(--sombra);
}

.card-propuesta h3 {
    color: var(--verde-principal);
    margin-bottom: 8px;
    font-size: 1.15rem;
}

.card-propuesta p {
    color: var(--texto-light);
    margin-bottom: 16px;
    line-height: 1.5;
}

.vote-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
    background: var(--verde-principal);
    color: var(--blanco);
    text-align: center;
    padding: 10px 20px;
    font-size: 0.8rem;
    margin-top: auto;
}

/* ========================================
   INNER TOPBAR (paginas internas)
   ======================================== */
.inner-topbar {
    background: linear-gradient(180deg, var(--blanco) 0%, #f5f8f2 100%);
    display: flex;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 3px solid;
    border-image: linear-gradient(90deg, var(--verde-principal), var(--verde-boton)) 1;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 10;
}

.inner-topbar .logo-inner {
    width: 70px;
    filter: drop-shadow(0 2px 6px rgba(126, 143, 107, 0.25));
}

.inner-topbar .inner-center {
    flex: 1;
    text-align: center;
}

.inner-topbar .inner-title {
    color: var(--verde-principal);
    font-size: 1.15rem;
    font-weight: bold;
    letter-spacing: 4px;
}

.inner-topbar .inner-subtitle {
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--verde-hover);
}

.inner-topbar .inner-vivienda {
    font-size: 0.72rem;
    font-weight: bold;
    color: var(--blanco);
    margin-top: 3px;
    background: var(--verde-principal);
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
}

/* ========================================
   INNER NAV (barra navegacion interna)
   ======================================== */
.inner-nav {
    background: linear-gradient(135deg, var(--verde-principal) 0%, var(--verde-hover) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    flex-wrap: wrap;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.inner-nav .nav-title {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 2px;
    flex: 1;
    text-align: center;
    text-transform: uppercase;
    position: relative;
    padding-bottom: 4px;
}

.inner-nav .nav-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
}

.inner-nav .nav-link {
    color: white;
    font-size: 0.8rem;
    padding: 6px 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.inner-nav .nav-link:hover {
    border-color: white;
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
}

/* ========================================
   ADMIN - GreenQuart Admin Panel
   ======================================== */
.gq-admin-wrapper {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--fondo);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.gq-admin-header {
    background: var(--verde-principal);
    padding: 16px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gq-admin-header .admin-logo {
    width: 80px;
}

.gq-admin-header .admin-title-group {
    text-align: center;
    flex: 1;
}

.gq-admin-header .admin-title {
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 4px;
}

.gq-admin-header .admin-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.gq-admin-header .admin-user {
    color: white;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gq-admin-header .admin-user a {
    color: white;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.gq-admin-header .admin-user a:hover {
    background: rgba(255, 255, 255, 0.25);
}

.gq-admin-nav {
    background: var(--verde-hover);
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    flex-wrap: wrap;
}

.gq-admin-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.gq-admin-nav a:hover {
    background: rgba(255, 255, 255, 0.15);
    text-decoration: none;
}

.gq-admin-nav a.active {
    background: rgba(255, 255, 255, 0.2);
}

.gq-admin-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    flex: 1;
}

.gq-admin-card {
    background: white;
    border-radius: var(--radio);
    box-shadow: 0 4px 15px var(--sombra);
    padding: 24px;
    margin-bottom: 20px;
}

.gq-admin-card h2 {
    color: #3d4e2f;
    font-size: 1.2rem;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--verde-claro);
}

.gq-admin-tools {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gq-admin-tools .tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 22px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: white;
    border: none;
    cursor: pointer;
}

.gq-admin-tools .tool-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.gq-admin-tools .tool-btn.btn-resultados {
    background: var(--verde-principal);
}

.gq-admin-tools .tool-btn.btn-excel {
    background: var(--verde-boton);
}

.gq-admin-tools .tool-btn.btn-importar {
    background: #558B2F;
}

.gq-admin-footer {
    background: var(--verde-principal);
    color: white;
    text-align: center;
    padding: 10px 20px;
    font-size: 0.8rem;
    margin-top: auto;
}

.gq-admin-section-title {
    color: #3d4e2f;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 24px 0 12px;
    padding-left: 12px;
    border-left: 3px solid var(--verde-boton);
}

.gq-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.gq-admin-table th {
    background: var(--verde-principal);
    color: white;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
}

.gq-admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
}

.gq-admin-table tr:nth-child(even) td {
    background: #fafbf8;
}

.gq-admin-table tr:hover td {
    background: var(--verde-claro);
}

.gq-admin-table a {
    color: var(--verde-boton);
    font-weight: 600;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 768px) {
    .topbar {
        padding: 12px 16px;
        min-height: 70px;
    }

    .topbar .logo-topbar {
        width: 80px;
    }

    .topbar-center .titulo {
        font-size: 1rem;
        letter-spacing: 3px;
    }

    .topbar-center .subtitulo-top {
        font-size: 0.7rem;
    }

    .menu {
        gap: 10px;
        padding: 14px 16px;
    }

    .menu-card {
        padding: 14px 14px;
        min-width: 110px;
    }

    .menu-icon {
        font-size: 1.5rem;
    }

    .menu-label {
        font-size: 0.8rem;
    }

    .inner-topbar {
        padding: 10px 14px;
    }

    .inner-topbar .logo-inner {
        width: 55px;
    }

    .inner-topbar .inner-title {
        font-size: 0.95rem;
        letter-spacing: 2px;
    }

    .gq-admin-header {
        padding: 12px 16px;
    }

    .gq-admin-header .admin-logo {
        width: 60px;
    }

    .gq-admin-header .admin-title {
        font-size: 1rem;
    }

    .gq-admin-nav {
        gap: 6px;
        padding: 8px 12px;
    }

    .gq-admin-nav a {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* ========================================
   RESPONSIVE - MOVIL
   ======================================== */
@media (max-width: 480px) {
    .topbar {
        padding: 10px 12px;
        flex-wrap: wrap;
        min-height: auto;
    }

    .topbar .logo-topbar {
        width: 50px;
        order: 1;
    }

    .topbar-right {
        order: 2;
        margin-left: auto !important;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .topbar-center {
        position: static;
        transform: none;
        order: 3;
        width: 100%;
        margin-top: 4px;
        padding-top: 4px;
        border-top: 1px solid #eee;
    }

    .topbar-center .titulo {
        font-size: 0.9rem;
        letter-spacing: 2px;
    }

    .topbar-center .subtitulo-top,
    .topbar-center .area-privada {
        font-size: 0.65rem;
    }

    .btn-logout {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .menu {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 8px;
    }

    .menu-card {
        padding: 10px 6px;
        min-width: auto;
        gap: 4px;
        border-radius: 8px;
    }

    .menu-icon {
        font-size: 1.3rem;
    }

    .menu-label {
        font-size: 0.65rem;
        letter-spacing: 0;
    }

    .galeria {
        padding: 8px 8px 4px;
    }

    .galeria h2 {
        font-size: 0.8rem;
        margin-bottom: 4px;
        letter-spacing: 2px;
    }

    .galeria h2::before,
    .galeria h2::after {
        width: 20px;
        margin: 0 8px;
    }

    .controls {
        height: 36px;
        margin-top: 6px;
    }

    .btn-slider {
        padding: 6px 10px;
        font-size: 1rem;
    }

    .footer {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .card-auth {
        padding: 28px 20px;
    }

    .card-auth .logo {
        max-width: 140px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .card-propuesta {
        padding: 18px;
    }

    .vote-options {
        flex-direction: column;
    }

    .btn-vote {
        width: 100%;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .inner-topbar {
        padding: 8px 10px;
        flex-wrap: wrap;
    }

    .inner-topbar .logo-inner {
        width: 45px;
        order: 1;
    }

    .inner-topbar .btn-logout {
        order: 2;
        margin-left: auto !important;
    }

    .inner-topbar .inner-center {
        order: 3;
        flex: none;
        width: 100%;
        text-align: center;
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid #eee;
    }

    .inner-topbar .inner-title {
        font-size: 0.85rem;
    }

    .inner-nav {
        gap: 6px;
        padding: 8px 12px;
    }

    .inner-nav .nav-title {
        font-size: 0.9rem;
    }

    .inner-nav .nav-link {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    .gq-admin-header {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .gq-admin-header .admin-title-group {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }

    .gq-admin-header .admin-title {
        font-size: 0.9rem;
    }

    .gq-admin-tools {
        flex-direction: column;
    }

    .gq-admin-tools .tool-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== SAFE AREA (iPhone notch) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .topbar {
        padding-top: calc(16px + env(safe-area-inset-top));
    }

    .inner-topbar {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
}

/* ===== FORZAR MODO CLARO ===== */
@media (prefers-color-scheme: dark) {
    html, body {
        background: var(--fondo) !important;
        color: var(--texto) !important;
    }

    .topbar, .card-auth, .menu-card, .slide, .card-propuesta, .inner-topbar, .gq-admin-card {
        background: var(--blanco) !important;
        color: var(--texto) !important;
    }

    input, select {
        background: var(--blanco) !important;
        color: var(--texto) !important;
    }
}
