/* --- Variables y Estilos Globales --- */
:root {
    --primary-color: #388e3c;
    --secondary-color: #66bb6a;
    --accent-color: #ffffff;
    --text-color: #333333;
    --border-color: #a5d6a7; 
    --error-color: #c62828;
    --success-color: #2e7d32;
    --border-radius: 8px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #e8f5e9;
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* --- Estructura Principal y Contenedores --- */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

.main-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    width: 100%;
    box-sizing: border-box;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Cabecera --- */
.main-header {
    background-color: var(--accent-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    height: 50px;
    display: block;
}

.user-menu {
    position: relative;
}

.user-menu-toggle {
    background-color: transparent;
    border: 1px solid #ccc;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: background-color 0.3s ease;
}

.user-menu-toggle:hover {
    background-color: #f0f0f0;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    background-color: var(--accent-color);
    min-width: 160px;
    box-shadow: var(--box-shadow);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    transition: background-color 0.2s ease;
}

.dropdown-content a:hover {
    background-color: #f1f8e9;
}

.dropdown-content.show {
    display: block;
}

.hamburger {
    display: none;
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
}

/* --- Contenido Principal y Resultados (Homepage) --- */
.main-content-area {
    width: 100%;
    padding: 40px 0;
}

.page-title {
    text-align: center;
    font-size: 2.8rem;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.results-frame {
    background-color: #fff;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
}

.results-title {
    text-align: left;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.ads-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 700px;
    overflow-y: auto;
    padding-right: 15px;
}

/* Tarjeta de Anuncio de Alumno */
.ad-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.ad-card-link:hover .ad-card-content-preview {
    color: var(--primary-color);
}

.ad-card-new {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s ease;
}

.ad-card-new:hover {
    border-color: var(--primary-color);
}

.ad-card-header, .ad-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.ad-card-header {
    margin-bottom: 1rem;
}

.ad-card-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag-item.small {
    font-size: 0.8rem;
    padding: 4px 10px;
    background-color: #f0f0f0;
    border-radius: 15px;
}

.ad-card-timestamp {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #757575;
    white-space: nowrap;
}

.ad-card-content-preview {
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
    margin-top: 0;
    margin-bottom: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    transition: color 0.2s ease;
}

.ad-card-body {
    margin-bottom: 1rem;
}

.ad-card-body .ad-content {
    font-size: 1.1rem;
    font-weight: normal;
    color: #333;
    margin-top: 0;
    margin-bottom: 0;
    display: block; 
    overflow: visible;
    text-overflow: initial;
    -webkit-line-clamp: none;
}

.ad-card-footer {
    margin-top: 1.5rem;
}

.ad-author {
    font-size: 0.9rem;
    color: #555;
}

.button-contact {
    background-color: var(--primary-color);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.button-contact:hover {
    background-color: var(--secondary-color);
}

.button-contact-fake {
    background-color: var(--primary-color);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--border-radius);
    font-weight: bold;
    font-size: 0.9rem;
}

/* Paginación */
.pagination {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: center;
}

.pagination ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 5px;
}

.pagination a, .pagination .active {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--primary-color);
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.pagination a:hover {
    background-color: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

.pagination .active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    cursor: default;
}

/* Formularios (Generales) */
.search-form {
    display: flex;
    justify-content: center;
    background-color: #fff;
    padding: 12px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 800px;
    margin: 0 auto 2rem;
}

.search-form .form-group {
    display: flex;
    flex-direction: row;
    margin-bottom: 0;
}

.search-form select,
.search-form input {
    border: none;
    padding: 15px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
}

.search-form select {
    background-color: #f0f0f0;
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
    border-right: 1px solid #ddd;
}

.search-form input {
    flex-grow: 1;
    min-width: 300px;
}

.search-form button {
    border: none;
    padding: 15px;
    font-size: 1rem;
    background-color: var(--primary-color);
    color: var(--accent-color);
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.search-form button:hover {
    background-color: var(--secondary-color);
}

.form-container {
    background-color: var(--accent-color);
    border: 1px solid #ddd;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 450px;
}

.form-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-container input[type="email"],
.form-container input[type="password"],
.form-container input[type="text"],
.form-container input[type="tel"],
.form-container textarea,
.form-container select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-size: 1rem;
    box-sizing: border-box;
}

.form-container textarea#mensaje {
    resize: none;
}

.form-container fieldset {
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    padding: 1rem;
}

.form-container legend {
    padding: 0 0.5rem;
    font-weight: 500;
}

.radio-group {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.radio-group label {
    display: inline-block;
    margin-left: 0.5rem;
    margin-bottom: 0;
    font-weight: normal;
}

.button-primary {
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: var(--accent-color);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.button-primary:hover {
    background-color: var(--secondary-color);
}

.form-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid transparent;
}
.message.error {
    background-color: #ffcdd2;
    color: var(--error-color);
    border-color: var(--error-color);
}
.message.success {
    background-color: #c8e6c9;
    color: var(--success-color);
    border-color: var(--success-color);
}

/* --- Página de Perfil y Resultados de Profesores --- */
.profile-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.profile-sidebar {
    background-color: #f9f9f9;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid #e0e0e0;
    text-align: center;
}

.profile-photo-container {
    width: 150px;
    height: 150px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--accent-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.profile-photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-content {
    background-color: var(--accent-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    box-sizing: border-box;
}

.form-section {
    margin-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 1.5rem;
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 1rem;
}

.form-section h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
}

.checkbox-item label {
    display: inline-block;
    margin-left: 0.5rem;
    font-weight: normal;
}

.checkbox-item.inline {
    margin-top: 0.5rem;
}

.select-all-links {
    font-size: 0.8rem;
    font-weight: normal;
    margin-left: 0.5rem;
}

.select-all-links a {
    text-decoration: none;
    color: var(--secondary-color);
}

.select-all-links a:hover {
    text-decoration: underline;
}

.content-section {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
}
.ad-card-full {
    background-color: #fff;
    padding: 2rem;
    border-radius: var(--border-radius);
    border: 1px solid #e0e0e0;
}

.dashboard-actions a.button-primary {
    display: inline-block;
    width: auto;
    text-decoration: none;
    padding: 10px 20px;
    margin-top: 1rem;
}

.search-summary {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #ddd;
    padding-bottom: 1rem;
}

.search-results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.no-results {
    text-align: center;
    padding: 3rem;
    background-color: #f9f9f9;
    border-radius: var(--border-radius);
}

.professor-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--accent-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.professor-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.professor-card-image {
    width: 100%;
    height: 150px;
    background-color: #e0e0e0;
}

.professor-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.professor-card-content {
    padding: 1rem 1.5rem 1.5rem;
}

.professor-card-content h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.professor-card-meta {
    margin-bottom: 0.5rem;
}

.professor-card-excerpt {
    margin-bottom: 1.5rem;
    color: #444;
}

.button-secondary {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.button-secondary:hover {
    background-color: var(--primary-color);
    color: var(--accent-color);
}

.profile-section {
    margin-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 1.5rem;
}
.profile-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}
.profile-section h3 {
    margin-top: 0;
    color: var(--primary-color);
}
.profile-section p {
    white-space: pre-wrap;
    word-break: break-word;
}

.online-badge {
    display: inline-block;
    background-color: #e8f5e9;
    color: var(--primary-color);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: bold;
}

.profile-sidebar .online-badge {
    margin-top: 0.5rem;
}

.phone-info {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #555;
}

.tag-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-item {
    background-color: #f0f0f0;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
}

/* --- ESTILOS PARA LA PÁGINA DE MENSAJES --- */
.messages-layout-new {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: calc(100vh - 180px);
    background-color: var(--accent-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    margin: 2rem auto;
}
.conversations-list-new {
    flex: 0 0 320px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background-color: #f9f9f9;
}
.conv-header {
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
    color: var(--primary-color);
}
.conv-list-body {
    overflow-y: auto;
    flex: 1;
}
.no-conv {
    padding: 1rem;
    color: #888;
}
.convo-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    transition: background-color 0.2s ease;
}
.convo-item.active {
    background-color: #e8f5e9;
}
.convo-item:hover {
    background-color: #f0f0f0;
}
.convo-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #bdbdbd;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    font-size: 1.2rem;
}
.convo-details {
    overflow: hidden;
    flex: 1;
}
.convo-user {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.convo-excerpt {
    display: block;
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unread-badge, .unread-badge-menu {
    background-color: var(--primary-color);
    color: #fff;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    margin-left: auto;
}
.messages-content-new {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f9f9f9;
    display: flex;
    justify-content: center;
    align-items: center;
}
.chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-color);
}
.messages-chatbox-new {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #e8f5e9;
}
.message-bubble-new {
    max-width: 75%;
    padding: 10px 15px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    word-wrap: break-word;
}
.message-bubble-new p { margin: 0 0 5px 0; }
.message-bubble-new .msg-time { font-size: 0.75rem; text-align: right; }
.message-bubble-new.sent {
    background-color: var(--primary-color);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.message-bubble-new.sent .msg-time { color: rgba(255,255,255,0.7); }
.message-bubble-new.received {
    background-color: var(--accent-color);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.message-bubble-new.received .msg-time { color: #888; }
.message-reply-form {
    border-top: 1px solid #e0e0e0;
    padding: 1rem;
    background-color: #f9f9f9;
}
.message-reply-form form { display: flex; gap: 10px; align-items: flex-end; }
.message-reply-form textarea { 
    flex: 1; 
    min-height: 40px;
    max-height: 120px;
    resize: vertical;
    padding: 10px; 
    border-radius: 18px; 
    border: 1px solid #ccc; 
    font-family: 'Poppins', sans-serif; 
    font-size: 1rem; 
    box-sizing: border-box;
    line-height: 1.5;
}
.message-reply-form button.button-primary { 
    width: auto;
    padding: 10px 20px; 
    border-radius: 18px;
    font-size: 1rem;
    align-self: flex-end;
}
.no-conversation-selected {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #888;
    text-align: center;
    font-size: 1.2rem;
}

/* Pie de Página */
.main-footer {
    text-align: center;
    padding: 20px 0;
    background-color: var(--accent-color);
    margin-top: auto;
    font-size: 0.9rem;
}

/* --- RESPONSIVIDAD (Móviles) --- */
@media (max-width: 991px) {
    main {
        padding: 1rem 0;
        align-items: flex-start;
    }

    .main-nav {
        display: none;
        flex-direction: column;
        width: 100%;
        background-color: white;
        position: absolute;
        top: 66px;
        left: 0;
        padding: 20px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    
    .main-nav.active {
        display: flex;
    }

    .hamburger {
        display: block;
    }

    .logo {
        height: 35px;
    }

    .page-title {
        font-size: 2rem;
    }

    .search-form {
        flex-direction: column;
        padding: 20px;
        gap: 10px;
    }

    .search-form select,
    .search-form input,
    .search-form button {
        border-radius: var(--border-radius);
        width: 100%;
        box-sizing: border-box;
    }
    .search-form select {
        border: 1px solid #ddd;
    }
    .search-form input {
       border: 1px solid #ddd;
    }

    .messages-layout-new {
        flex-direction: column;
        height: auto;
        margin: 1rem auto;
    }
    .conversations-list-new {
        flex: none;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 40vh;
    }
    .messages-content-new {
        flex: 1;
        width: 100%;
    }
    .message-bubble-new {
        max-width: 90%;
    }
}

@media (min-width: 768px) {
    .professor-card {
        flex-direction: row;
    }
    .professor-card-image {
        flex: 0 0 200px;
        height: auto;
    }
}

@media (min-width: 992px) {
    .profile-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .profile-sidebar {
        flex: 0 0 300px;
        position: sticky;
        top: 100px;
    }

    .profile-content {
        flex: 1;
    }
}