* { box-sizing: border-box; }

html {
    font-size: 16px;
}

html, body {
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f2f4f7;
    color: #333;
    line-height: 1.5;
}

/* ============================= */
/* HEADER */
/* ============================= */

header {
    background: #0d3b66;
    padding: 0.8rem 2rem;
    border-bottom: 3px solid #ffc107;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-img {
    height: 2.6rem;
    max-width: 100%;
    border-radius: 7px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.5);
}

.header-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    color: white;
}

.header-nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Hamburger menu */
.header-hamburger {
    position: relative;
}
.hamburger-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.hamburger-btn:hover {
    opacity: 1;
}
.hamburger-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 150px;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
}
.hamburger-dropdown.open {
    display: flex;
}
.hamburger-link {
    display: block;
    padding: 11px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.1s;
}
.hamburger-link:hover {
    background: #f5f5f5;
}
.hamburger-link--sair {
    color: #c0392b;
    border-top: 1px solid #eee;
}

.header-username {
    font-size: 0.75rem;
    color: #cde;
}

.header-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}


.header-btn-admin {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
    border-radius: 5px;
    font-weight: bold;
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}


.header-btn-login {
    color: white;
    text-decoration: none;
    font-weight: bold;
    background: #28a745;
    padding: 8px 15px;
    border-radius: 5px;
    white-space: nowrap;
}

/* ============================= */
/* LAYOUT */
/* ============================= */

.page-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 260px;
    gap: 1rem;
    max-width: 1600px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    align-items: start;
}

.ad-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ad-box {
    background: #e6e6e6;
    border: 2px dashed #c8c8c8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-weight: 600;
    font-size: 0.9rem;
    width: 100%;
}

.vertical-ad { height: 18rem; }
.horizontal-ad { height: 12rem; }

/* Linha inferior de publicidade — 3 rectângulos altos lado a lado */
.ad-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
}
.ad-row .ad-box { height: 22rem; }

/* Publicidade lateral em mobile — oculta no desktop */
.mobile-lateral-ads { display: none; }

/* Card de escola patrocinada */
.school-card-sponsored {
    position: relative;
    border: 2px solid #f0c040;
    border-radius: 10px;
    background: #fffdf0;
    margin-bottom: 10px;
}
.sponsored-badge {
    position: absolute;
    top: 8px;
    right: 10px;
    background: #f0c040;
    color: #5a4000;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* Anúncio real (com imagem) */
@keyframes ad-glow {
    0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,51,102,0.12); }
    50%       { box-shadow: 0 6px 28px rgba(0,51,102,0.48), 0 0 0 4px rgba(0,51,102,0.30); }
}
.ad-real {
    background: white;
    border: 1px solid #e0e6f0;
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
    text-decoration: none;
    animation: ad-glow 1.6s ease-in-out infinite;
}
.ad-real:hover { animation: none; box-shadow: 0 6px 24px rgba(0,51,102,0.30), 0 0 0 3px rgba(0,51,102,0.22); }
.ad-real img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 11px; }

/* Destaque topo de resultados */
.destaque-ads {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}
.destaque-ad-card {
    display: block;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    transition: box-shadow 0.15s;
    background: white;
    max-height: 130px;
}
.destaque-ad-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.1); }
.destaque-ad-card img { width: 100%; max-height: 130px; object-fit: cover; display: block; }
.destaque-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.45);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.main-content {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.container {
    width: 100%;
    background: white;
    padding: 2rem;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
    overflow-wrap: break-word;
}

/* ============================= */
/* SEARCH */
/* ============================= */

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-box input {
    flex: 1;
    min-width: 200px;
    padding: 0.9rem;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 0.7rem;
}

.search-box button {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.9rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
}

/* ============================= */
/* FILTERS */
/* ============================= */

.filter-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
    background: #f7f7f7;
    padding: 1.5rem;
    border-radius: 12px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.filter-group select {
    width: 100%;
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* ============================= */
/* RESULTS */
/* ============================= */

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.order-form {
    max-width: 100%;
}

.order-form select {
    max-width: 100%;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.school-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.4rem;
    margin-bottom: 0.9rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    flex-wrap: wrap;
    gap: 1rem;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.school-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    transform: translateY(-1px);
}

.school-name {
    word-break: break-word;
    margin: 0 0 4px 0;
}

.school-location,
.school-meta,
.school-info {
    margin: 2px 0;
    line-height: 1.4;
}

.school-name a {
    display: inline-block;
    max-width: 100%;
    text-decoration: none;
    color: #0d3b66;
    font-weight: 600;
    font-size: 1.1rem;
}

.rating-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    background: #ffdc15;
    white-space: nowrap;
}

.no-rating {
    background: #fdeddc;
    color: #d38181;
}

/* ============================= */
/* SCHOOL PAGE */
/* ============================= */

.school-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

/* ESSENCIAL PARA GRID NÃO ESTOURAR */
.school-layout > * {
    min-width: 0;
}

.rating-large {
    margin-top: 1rem;
    font-size: 1.4rem;
    font-weight: bold;
    background: #ffc107;
    display: inline-block;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    max-width: 100%;
}

/* FORM 100% CONTROLADO */
.rating-form {
    width: 100%;
}

.rating-form input,
.rating-form select,
.rating-form textarea,
.rating-form button {
    width: 100%;
    max-width: 100%;
    display: block;
}

.rating-form textarea {
    resize: vertical;
}

/* BARRAS NUNCA ULTRAPASSAM */
.criteria-bar,
.progress-bar,
.rating-bar {
    width: 100%;
    max-width: 100%;
}

.criteria-bar > div,
.progress-bar > div,
.rating-bar > div {
    max-width: 100%;
}

/* REVIEWS */
.review-card {
    background: #fff;
    padding: 1rem;
    border-left: 4px solid #ffc107;
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.04);
    width: 100%;
}

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

@media (max-width: 1100px) {

    .page-layout {
        display: flex;
        flex-direction: column;
        max-width: 860px;
        margin: 0.5rem auto;
    }

    .ad-column {
        display: none;
    }

    .main-content {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Cards centrais sobem para cima do conteúdo em mobile */
    .ad-row {
        order: -1;
        margin: 0;
    }

    .ad-row .ad-box {
        height: auto;
        aspect-ratio: 4 / 5;
    }

    .mobile-lateral-ads {
        display: grid;
        grid-template-columns: repeat(2, 117px);
        justify-content: center;
        gap: 0.5rem;
        margin: 0.5rem auto 0.5rem;
    }
    .mobile-lateral-ads .ad-box {
        height: auto;
        aspect-ratio: 4 / 5;
    }

    .school-layout {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {

    .page-layout {
        max-width: 100%;
        padding: 0 1rem;
    }

    .filter-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {

    header {
        padding: 0.6rem 1rem;
    }

    .header-inner {
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.5rem;
    }

    .logo-img {
        height: 2rem;
    }

    .header-nav {
        align-items: flex-end;
        gap: 3px;
    }

    .header-nav-links {
        gap: 8px;
    }

    .header-btn-admin {
        font-size: 11px;
        padding: 4px 8px;
    }

    .header-link {
        font-size: 12px;
    }

    .header-btn-login {
        font-size: 12px;
        padding: 5px 10px;
    }

    .header-username {
        font-size: 0.65rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .order-form {
        width: 100%;
    }

    .order-form select {
        width: 100%;
    }

    .rating-large {
        display: block;
        width: 100%;
        text-align: center;
    }
}

/* ============================= */
/* NO ADS MODE */
/* ============================= */

.page-layout.no-ads {
    display: block;
}

.page-layout.no-ads .main-content {
    max-width: 900px;
    margin: 0 auto;
}

/* ============================= */
/* AUTH — Login, Registo, Admin  */
/* ============================= */

.auth-wrapper {
    display: flex;
    justify-content: center;
    padding: 40px 16px 60px;
    min-height: 60vh;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.10);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    border-top: 4px solid var(--card-accent, #003366);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
}

.auth-subtitle {
    font-size: 14px;
    color: #888;
    margin: 0;
}

.auth-alert--error {
    background: #fdecea;
    color: #a71d2a;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 18px;
    text-align: center;
}

.auth-alert--success {
    background: #e6f4ea;
    color: #1e7e34;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 18px;
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    letter-spacing: 0.3px;
}

.auth-input-wrap {
    position: relative;
}

.auth-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 15px;
    color: #222;
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    outline: none;
}

.auth-input:focus {
    border-color: #003366;
    box-shadow: 0 0 0 3px rgba(0,51,102,0.08);
    background: #fff;
}

.auth-input-wrap .auth-input {
    padding-right: 44px;
}

.auth-eye {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 0;
}

.auth-eye:hover { opacity: 1; }

.auth-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    margin-top: 4px;
    letter-spacing: 0.3px;
}

.auth-btn--primary {
    background: #003366;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,51,102,0.25);
}

.auth-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,51,102,0.35);
}

.auth-btn--danger {
    background: #dc3545;
    color: #fff;
    box-shadow: 0 4px 14px rgba(220,53,69,0.25);
}

.auth-btn--danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(220,53,69,0.35);
}

.auth-btn:active { transform: translateY(0); }

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: #777;
}

.auth-link {
    color: #003366;
    font-weight: 700;
    text-decoration: none;
}

.auth-link:hover { text-decoration: underline; }

.auth-hint {
    font-size: 11px;
    color: #aaa;
    margin: -10px 0 0;
    padding: 5px 0;
}

.auth-badge {
    display: inline-block;
    background: #fff0f0;
    color: #dc3545;
    border: 1px solid #f5c6cb;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 28px 20px;
        border-radius: 12px;
    }
    .auth-title { font-size: 20px; }
}