* { 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 > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

/* Nome do usuário */
header nav span {
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* evita quebra */
header nav a {
    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; }

.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.3rem 0;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 1rem;
}

.school-name {
    word-break: break-word;
}

.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: 1200px) {

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

    .ad-column {
        display: none;
    }

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

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

@media (max-width: 768px) {

    header {
        padding: 0.7rem 1rem;
    }

    header > div {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .logo-img {
        height: 2.2rem;
    }

    header nav {
        width: 100%;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: -8px;
    }

    header nav span {
        font-size: 0.65rem;
    }

    header nav a[href="/login"] {
        padding: 0.25rem 0.60rem;
        font-size: 0.60rem;
    }

    header nav a[href="/register"] {
        font-size: 0.60rem;
    }

    .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-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; }
}