/* === Enhanced GUI Styles V8 - Correctly Scoped Chat GUI === */

/* --- Variables --- */
:root {
    /* -- Blue Theme Colors -- */
    --primary-color: #3B82F6; /* Tailwind Blue 500 */
    --primary-dark: #2563EB; /* Tailwind Blue 600 */
    --gradient-start: #60A5FA; /* Tailwind Blue 400 */
    --gradient-end: #3B82F6; /* Tailwind Blue 500 */
    --input-focus-border: var(--primary-color);
    --input-focus-shadow: rgba(59, 130, 246, 0.25); /* Blue glow */
    --link-color: var(--primary-color);
    --link-hover: var(--primary-dark);

    /* -- Other Colors -- */
    --secondary-color: #8A2387; /* Purple (for accents) */
    --accent-color: #FFE66D; /* Yellow */
    --background-light: #f9fafd;
    --background-body: #f0f2f5; /* Body background */
    --background-white: #FFFFFF;
    --text-dark: #1f2937; /* Darker Grey/Blue */
    --text-medium: #4b5563; /* Medium Grey/Blue */
    --text-light: #6b7280; /* Lighter Grey/Blue */
    --border-color: #e5e7eb; /* Softer border consistent with example */
    --input-border: #d1d5db; /* Input border */
    --success-bg: #d1fae5; /* Lighter Green */
    --success-text: #065f46; /* Darker Green */
    --success-border: #a7f3d0;
    --error-bg: #fee2e2; /* Lighter Red */
    --error-text: #991b1b; /* Darker Red */
    --error-border: #fecaca;
    --danger-color: #ef4444; /* Standard Red */
    --danger-dark: #dc2626; /* Darker Red */
    --danger-gradient-start: #f87171; /* Lighter Red for gradient */

    /* -- Base Styles -- */
    --font-family-base: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 10px;
    --border-radius-large: 16px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    --box-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.1);
    --box-shadow-card: 0 8px 25px rgba(0, 0, 0, 0.08);
    --box-shadow-card-hover: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* --- Base & Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: var(--font-family-base);
    background-color: var(--background-body);
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Add padding to prevent content from touching screen edges on very small screens */
    padding: 0 10px; /* Added padding */
}
.main-content {
    flex-grow: 1;
    padding: 20px 15px;
    width: 100%; /* Ensure main content takes full width */
}
.main-content.page-matches {
    padding: 0; /* Remove padding on chat page */
}

/* --- Containers --- */
.container {
    width: 100%; /* Ensure container is always 100% width up to max-width */
    max-width: 550px;
    margin: 30px auto;
    padding: 35px 45px;
    background-color: var(--background-white);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    /* Add padding adjustments for smaller screens */
    padding: 20px; /* Adjusted padding */
}
.container-wide {
    max-width: 900px;
}
.container-full {
    max-width: 1100px;
}
.container-tight {
    max-width: 450px;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    text-align: center;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-dark);
}
h1 {
    font-size: 2.1rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}
h2 {
    font-size: 1.5rem;
    margin-bottom: 1.8rem;
    color: var(--text-medium);
}
h3 {
    font-size: 1.25rem;
    margin-bottom: 1.2rem;
}
h4 {
    font-size: 1.05rem;
    margin-bottom: 0.8rem;
    color: var(--text-medium);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
p {
    margin-bottom: 1rem;
    color: var(--text-light);
    text-align: center; /* Default paragraph text alignment */
    font-size: 0.95rem;
}
p.text-left {
    text-align: left;
}
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--link-hover);
    text-decoration: none;
}
small, .form-text, .message-meta, .last-activity-time {
    font-size: 0.8rem;
    color: var(--text-light);
}
hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* --- Forms --- */
.form-wrapper {
    margin-top: 1.5rem;
}
.form-group {
    margin-bottom: 1.5rem;
}
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-medium);
    font-size: 0.9rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: var(--background-white);
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="tel"]:focus,
select:focus,
textarea:focus {
    border-color: var(--input-focus-border);
    outline: 0;
    box-shadow: 0 0 0 0.2rem var(--input-focus-shadow);
}
textarea {
    resize: vertical;
    min-height: 100px;
}
select {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236C757D%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.65em auto;
    padding-right: 2.5rem;
}
input[type="file"] {
    padding: 0.6rem;
    font-size: 0.9rem;
}
input[type="file"]::file-selector-button {
    padding: 0.6rem 0.9rem;
    margin-right: 10px;
    border: none;
    background-color: #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: inherit;
    font-weight: 500;
}
input[type="file"]::file-selector-button:hover {
    background-color: #dee2e6;
}
.form-text {
    margin-top: 0.5rem;
    display: block;
}
.form-profile-pic-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 3px solid var(--border-color);
    display: block;
}
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
}
.form-actions .btn {
    margin-top: 0; /* Remove top margin for buttons within form-actions */
}


/* --- Buttons --- */
.btn {
    display: inline-block;
    width: 100%;
    padding: 0.8rem 1.5rem;
    background-color: var(--primary-color);
    background-image: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-top: 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.btn:hover {
    background-size: 150% auto;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}
.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.btn:disabled {
    background-image: none;
    background-color: #adb5bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}
.btn-auto {
    width: auto;
}
.button {
    display: inline-block;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s ease;
    text-align: center;
    border: 1px solid transparent;
}
.btn.btn-secondary {
    background-image: none;
    background-color: var(--text-light);
    border: 1px solid var(--text-light);
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.btn.btn-secondary:hover {
    background-color: var(--text-medium);
    border-color: var(--text-medium);
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-hover);
}
.btn-like {
    background-image: linear-gradient(45deg, #4CAF50, #8BC34A);
    background-color: #4CAF50;
}
.btn-like:hover {
    background-size: 150% auto;
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.3);
}
.btn-pass {
    background-image: linear-gradient(45deg, var(--danger-gradient-start), var(--danger-color));
    background-color: var(--danger-color);
}
.btn-pass:hover {
    background-image: linear-gradient(45deg, var(--danger-color), var(--danger-dark));
    background-color: var(--danger-dark);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.3);
}
.button-logout {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}
.button-logout:hover {
    background-color: var(--danger-dark);
    border-color: var(--danger-dark);
    color: white;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}
.btn-edit-profile {
    display: inline-block;
    width: auto;
    padding: 0.7rem 1.8rem;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 50px;
    font-weight: 500;
    text-decoration: none;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-edit-profile:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--input-focus-shadow);
}

/* --- Alerts / Messages --- */
.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    text-align: left;
    font-size: 0.95rem;
    word-break: break-word; /* Ensure alert text wraps */
}
.alert-error {
    color: var(--error-text);
    background-color: var(--error-bg);
    border-color: var(--error-border);
}
.alert-error a {
    color: var(--error-text);
    font-weight: bold;
}
.alert-success {
    color: var(--success-text);
    background-color: var(--success-bg);
    border-color: var(--success-border);
}
.match-notification {
    background-image: linear-gradient(45deg, var(--secondary-color), #A546A0);
    background-color: var(--secondary-color);
    color: white;
    text-align: center;
    font-weight: bold;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1.5rem auto;
    max-width: 500px;
    word-break: break-word; /* Ensure notification text wraps */
}

/* --- Profile Cards --- */
.profile-card {
    border: none;
    border-radius: var(--border-radius-large);
    padding: 30px;
    background-color: var(--background-white);
    max-width: 450px;
    margin: 20px auto;
    box-shadow: var(--box-shadow-card);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%; /* Ensure profile card takes full width up to max-width */
    padding: 20px; /* Adjusted padding for smaller screens */
}
.profile-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--box-shadow-card-hover);
}
.profile-card img.profile-pic {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1.5rem auto;
    border: 6px solid var(--background-white);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    background-color: #e9ecef;
    vertical-align: middle;
}
.profile-card h3 {
    margin-bottom: 0.25rem;
    font-size: 1.7rem;
    font-weight: 700;
}
.profile-card .age-major {
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 1rem;
}
.profile-card .bio {
    font-size: 0.95rem;
    color: var(--text-medium);
    text-align: center; /* Set text alignment to center for bio */
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    line-height: 1.7;
    word-break: break-word; /* Ensure bio text wraps */
    overflow-wrap: anywhere; /* Allow breaking anywhere */
}
.profile-card .liked-you-text {
    font-size: 0.9em;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}
.profile-card .interaction-buttons {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    flex-wrap: wrap; /* Allow buttons to wrap */
}
.profile-card .interaction-buttons form {
    display: inline-block;
    width: 48%;
    /* Adjust width for smaller screens if needed */
    flex-basis: calc(50% - 0.5rem); /* Use flex-basis for better control */
    min-width: 120px; /* Ensure buttons don't become too small */
}
.profile-card .interaction-buttons button {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
}

/* --- Dashboard --- */
.dashboard-nav ul {
    list-style: none;
    padding: 0;
    margin: 30px 0;
    text-align: center;
    flex-wrap: wrap; /* Allow nav items to wrap */
    justify-content: center; /* Center nav items when wrapped */
    display: flex; /* Use flexbox for centering and wrapping */
}
.dashboard-nav li {
    display: inline-block;
    margin: 8px;
}
.dashboard-nav a.button {
    background-color: var(--background-white);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 50px;
    padding: 10px 25px;
}
.dashboard-nav a.button:hover,
.dashboard-nav a.button:focus {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--input-focus-shadow);
}
.dashboard-nav a.button-logout {
    border-color: var(--danger-color);
    color: var(--danger-color);
    background-color: transparent;
}
.dashboard-nav a.button-logout:hover,
.dashboard-nav a.button-logout:focus {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}
.dashboard-content-area {
    margin-top: 30px;
    padding: 30px;
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow);
    width: 100%; /* Ensure dashboard area takes full width */
    padding: 20px; /* Adjusted padding */
}
.dashboard-content-area h2 {
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.dashboard-content-area ul {
    list-style: none;
    padding-left: 0;
    line-height: 1.8;
    color: var(--text-medium);
}
.dashboard-content-area li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
    word-break: break-word; /* Ensure list item text wraps */
}
.dashboard-content-area li::before {
    content: '✓';
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* === Chat Interface === */
.page-matches .chat-container,
.chat-container {
    width: 100%; /* Use 100% width */
    max-width: 1100px;
    height: calc(100vh - 120px);
    max-height: 800px;
    background-color: var(--background-white);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow);
    display: flex;
    overflow: hidden;
    margin: 20px auto;
    border: 1px solid var(--border-color);
    /* Add padding to prevent content touching edges on very small screens, especially if margin is 0 */
    padding: 0 10px; /* Added padding */
}

/* SIDEBAR HEADER on Desktop: Centered Title, Arrow Absolute */
.chat-container .sidebar .header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.chat-container .sidebar .header a {
    position: absolute;
    left: 1rem;
}
.chat-container .sidebar .header h2 {
    margin: 0;
}

/* SIDEBAR (rest) */
.chat-container .search-container {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.chat-container .search-box {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--input-border);
    background-color: var(--background-light);
    font-size: 0.9rem;
}
.chat-container .search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--background-white);
    box-shadow: 0 0 0 0.15rem var(--input-focus-shadow);
}
.chat-container .contact-list {
    flex-grow: 1;
    overflow-y: auto;
    /* Ensure contact list takes full width available in sidebar */
    width: 100%;
}
.chat-container .contact {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 4px solid transparent;
    width: 100%; /* Ensure contact item takes full width */
}
.chat-container .contact:hover {
    background-color: var(--background-light);
}
.chat-container .contact.active {
    background-color: #e7f0ff;
    border-left-color: var(--primary-color);
}
.chat-container .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 0.8rem;
    object-fit: cover;
    background-color: #e5e7eb;
    flex-shrink: 0;
    border: 2px solid transparent;
}
.chat-container .contact.active .avatar {
    border-color: rgba(var(--primary-color), 0.5);
}
.chat-container .contact-info {
    flex: 1;
    overflow: hidden;
    /* Ensure contact info takes available space and handles overflow */
    min-width: 0; /* Allow flex item to shrink below content size */
}
.chat-container .contact-name {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 2px;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-container .contact.active .contact-name {
    font-weight: 600;
    color: var(--primary-dark);
}
.chat-container .last-activity-time {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* Unread style for contact */
.chat-container .contact.has-unread {
    background-color: #e5fae8; /* Light green */
    border-left-color: #02d11e;
}
.chat-container .contact.has-unread .contact-name {
    font-weight: 700;
    color: #02d11e;
}
.chat-container .contact.has-unread:hover {
    background-color: #ddf5df;
}
.chat-container .contact.active.has-unread {
    background-color: #ddf5df;
    border-left-color: #02d11e;
}
.chat-container .contact.active.has-unread span {
    color: #02d11e;
    font-weight: 700;
}
.chat-container .contact.active.has-unread .avatar {
    border-color: var(--primary-color);
}

/* Chat Area */
.chat-container .chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--background-white);
    height: 100%;
    overflow: hidden;
    /* Ensure chat area takes full width available */
    width: 100%;
}
.chat-container .chat-header {
    padding: 0.8rem 1.2rem;
    background-color: var(--background-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-height: 68px;
    justify-content: center;
    position: relative;
}
.chat-container .chat-header .contact-info {
    text-align: left;
    /* Ensure contact info takes available space */
    flex-grow: 1;
    min-width: 0; /* Allow flex item to shrink */
}
.chat-container .chat-header .contact-name {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap; /* Prevent wrapping in header */
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-container .chat-header-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    display: none;
}
.chat-container .chat-header-link.visible {
    display: flex;
}
.chat-container .chat-header .avatar {
    width: 42px;
    height: 42px;
    margin-right: 0.8rem;
    object-fit: cover;
}
.chat-container .chat-header-actions {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    position: absolute;
    right: 1.2rem;
}
.chat-container .action-icon {
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}
.chat-container .action-icon:hover {
    color: var(--primary-color);
}

/* Hide the mobile arrow by default (desktop). We'll show it in mobile media query below. */
.mobile-back-arrow {
    display: none;
}

/* Messages container */
.chat-container .messages-container {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden; /* Hide horizontal scrolling */
    padding: 1.5rem;
    background-color: var(--background-light);
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%; /* Ensure messages container takes full width */
}
.chat-container .messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
    width: 100%; /* Ensure messages list takes full width */
}
.chat-container .message {
    max-width: 70%;
    display: flex;
    /* Ensure message takes full width up to max-width */
    width: 100%;
}
.chat-container .message.received {
    align-self: flex-start;
}
.chat-container .message.sent {
    align-self: flex-end;
}
.chat-container .message-content {
    padding: 0.75rem 1.1rem;
    border-radius: 18px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
    position: relative;
    /* Ensure message content takes full width of its container (message) */
    width: 100%;
    word-wrap: break-word; /* Force wrapping for long text */
    overflow-wrap: anywhere; /* Allow breaking anywhere */
}
.chat-container .received .message-content {
    background-color: var(--background-white);
    color: var(--text-dark);
    border-top-left-radius: 6px;
}
.chat-container .sent .message-content {
    background-image: linear-gradient(to right, var(--gradient-start), var(--primary-color));
    background-color: var(--primary-color);
    color: white;
    border-top-right-radius: 6px;
}
.chat-container .message-text {
    /* Force wrapping for long text */
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.chat-container .message-meta {
    font-size: 0.7rem;
    margin-top: 4px;
    text-align: right;
}
.chat-container .sent .message-meta {
    color: rgba(255,255,255,0.8);
}
.chat-container .received .message-meta {
    color: var(--text-light);
}
.chat-container .icebreaker-message {
    align-self: center;
    background-color: #e2f3ff;
    color: #0c5460;
    border: 1px solid #b8daff;
    padding: 0.9rem 1.3rem;
    font-size: 0.95rem;
    border-radius: var(--border-radius);
    margin: 1rem auto;
    max-width: 80%;
    text-align: center;
    font-style: italic;
    word-break: break-word; /* Ensure icebreaker text wraps */
}

/* Input area */
.chat-container .input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--background-white);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    width: 100%; /* Ensure input area takes full width */
}
.chat-container .message-input {
    flex-grow: 1;
    padding: 0.8rem 1.4rem;
    border-radius: 24px;
    border: 1px solid var(--input-border);
    font-size: 0.95rem;
    background-color: var(--background-light);
    margin-right: 0.5rem;
    /* Ensure input takes available space and handles overflow */
    min-width: 0; /* Allow flex item to shrink */
}
.chat-container .message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--background-white);
    box-shadow: 0 0 0 0.15rem var(--input-focus-shadow);
}
.chat-container .input-area button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    margin-left: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}
.chat-container .input-area button#icebreaker-button {
    background: none;
    font-size: 1.6rem;
    color: var(--text-light);
    width: auto;
    height: auto;
}
.chat-container .input-area button#icebreaker-button:hover {
    color: var(--primary-color);
}
.chat-container .input-area button#icebreaker-button:disabled {
    color: #adb5bd;
    cursor: not-allowed;
}
.chat-container .input-area button.send-button {
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1rem;
}
.chat-container .input-area button.send-button:hover {
    background-color: var(--primary-dark);
}
.chat-container .input-area button.send-button:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
}

/* --- Profile Page Styles (Refined) --- */
.profile-details-container {
    max-width: 750px;
    width: 100%; /* Ensure profile container takes full width */
}
.profile-header {
    text-align: center;
    margin-bottom: 2rem;
}
.profile-pic-large {
    display: block;
    margin: 0 auto 1.5rem auto;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 6px solid var(--background-white);
    object-fit: cover;
    background-color: #f8f9fa;
    box-shadow: var(--box-shadow);
}
.profile-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-dark);
}
.profile-member-since {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}
.profile-section {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
    padding: 1rem 1.5rem; /* Adjusted padding */
}
.profile-section h4 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.6rem;
    font-weight: 600;
    font-size: 1.2rem;
}
.detail-item {
    display: flex;
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
    align-items: baseline;
    flex-wrap: wrap; /* Allow items to wrap */
}
.detail-item strong {
    flex-basis: 150px;
    flex-shrink: 0;
    color: var(--text-medium);
    font-weight: 500;
    margin-right: 1rem;
    /* Adjust flex-basis for smaller screens if needed */
    flex-basis: auto; /* Allow basis to be determined by content */
    margin-bottom: 0.25rem; /* Add margin below label when wrapped */
}
.detail-item span {
    flex-grow: 1;
    color: var(--text-dark);
    word-wrap: break-word;
    min-width: 0; /* Allow span to shrink */
}
.detail-item small {
    font-size: 0.8em;
    color: var(--text-light);
    margin-left: 0.5rem;
}
.profile-bio {
    line-height: 1.7;
    color: var(--text-dark);
    white-space: normal;
    text-align: center; /* Set text alignment to center for bio */
    margin-top: 0;
    word-break: break-word; /* Ensure bio text wraps */
    overflow-wrap: anywhere; /* Allow breaking anywhere */
}
.profile-bio.not-set {
    color: var(--text-light);
    font-style: italic;
}
.edit-button-container {
    text-align: right;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.btn-edit-profile {
    display: inline-block;
    width: auto;
    padding: 0.7rem 1.8rem;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 50px;
    font-weight: 500;
    text-decoration: none;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-edit-profile:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--input-focus-shadow);
}

/* --- Back Links --- */
.back-link, .back-link-chat {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 1.5rem;
    display: inline-block;
}
.back-link:hover, .back-link-chat:hover {
    text-decoration: underline;
}

/* --- Responsive: Single-Column Chat (WhatsApp style) --- */
@media (max-width: 768px) {
    body {
        padding: 0; /* Remove body padding in mobile view */
    }
    .main-content {
        padding: 0;
    }
    .chat-container {
        flex-direction: column;
        height: 100vh;
        max-height: none;
        margin: 0;
        border: none;
        border-radius: 0;
        padding: 0; /* Remove chat container padding in mobile view */
    }

    /* Hide chat area by default; show the sidebar (contact list) */
    .chat-container .chat-area {
        display: none;
    }
    .chat-container .sidebar {
        display: flex; /* Use flex for sidebar content */
        flex-direction: column; /* Stack sidebar content */
        width: 100%;
        /* Add height to sidebar to make it scrollable if needed */
        height: 100vh; /* Sidebar takes full viewport height */
        overflow-y: auto; /* Allow scrolling if contacts exceed height */
    }

    /* If user is viewing a chat, show chat, hide sidebar */
    .chat-container.mobile-chat-active .sidebar {
        display: none;
    }
    .chat-container.mobile-chat-active .chat-area {
        display: flex; /* Show chat area */
        flex-direction: column; /* Ensure chat area content is stacked */
        width: 100%;
        height: 100vh; /* Chat area takes full viewport height */
    }

    /* Remove these as sidebar and chat area now take full height */
    /*
    .matches-list {
        width: 100%;
        height: 30%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .chat-area {
        width: 100%;
        height: 70%;
    }
    */

    .back-link-chat {
        margin: 10px 15px;
    }
    .container, .form-container {
        margin: 10px;
        padding: 20px;
        width: calc(100% - 20px); /* Adjust width to account for margin */
    }
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.4rem;
    }
    .profile-section {
        padding: 1rem 1.5rem;
    }
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1.2rem;
    }
    .detail-item strong {
        margin-bottom: 0.25rem;
        flex-basis: auto;
    }

    /* Make the sidebar header simpler on mobile */
    .chat-container .sidebar .header {
        position: relative;
        justify-content: flex-start;
    }
    .chat-container .sidebar .header a {
        position: static;
        margin-right: 1rem;
    }
    .chat-container .sidebar .header h2 {
        flex-grow: 1;
        text-align: left;
        font-size: 1.2rem;
    }

    /* The back arrow is shown on mobile only */
    .mobile-back-arrow {
        display: inline-block;
        font-size: 1.25rem;
        color: var(--text-light);
        margin-right: 1rem;
        cursor: pointer;
    }

    /* Ensure profile bio is centered on mobile */
    .profile-bio {
        text-align: center; /* Align text to the center */
        margin: 0 auto; /* Center the block element itself */
        width: 100%; /* Ensure it takes full width within padding */
        display: block; /* Ensure it behaves as a block element */
        white-space: normal !important; /* Override pre-wrap on mobile */
    }
}
@media (max-width: 480px) {
    /* Removed height percentages for matches-list and chat-area
       as they now take full height in the 768px media query */
    /*
    .matches-list {
        height: 25%;
        max-height: 150px;
    }
    .chat-area {
        height: 75%;
    }
    */
    .chat-container .input-area {
         padding: 0.8rem; /* Adjusted padding */
    }
    .chat-container .message-input {
        padding: 0.6rem 1rem;
    }
    .chat-container .input-area button {
        width: 40px; /* Slightly smaller buttons */
        height: 40px;
        margin-left: 0.3rem; /* Adjusted margin */
    }
     .chat-container .input-area button.send-button {
         font-size: 1rem; /* Adjusted font size */
     }
    #icebreaker-button {
        font-size: 1.4rem;
    }
    .chat-container .message {
        max-width: 90%; /* Allow messages to take up more width */
    }
    .chat-container .message-content {
        padding: 0.6rem 0.9rem; /* Adjusted padding */
    }
    h1 {
        font-size: 1.6rem;
    }
    h2 {
        font-size: 1.3rem;
    }
    .container, .form-container {
        margin: 5px; /* Reduced margin */
        padding: 15px; /* Reduced padding */
        width: calc(100% - 10px); /* Adjust width to account for margin */
    }
    .profile-card {
        padding: 15px; /* Reduced padding */
    }
    .profile-section {
        padding: 1rem; /* Reduced padding */
    }
    .detail-item strong {
        margin-bottom: 0.2rem; /* Reduced margin */
    }
    .form-actions {
        flex-direction: column; /* Stack form actions */
        gap: 0.8rem; /* Reduced gap */
    }
    .form-actions .btn {
        width: 100%; /* Ensure buttons take full width */
        margin-top: 0; /* Remove top margin */
    }
    .profile-card .interaction-buttons form {
        width: 100%; /* Ensure interaction buttons take full width */
        flex-basis: auto;
        min-width: auto;
    }

     /* Ensure profile bio is centered on mobile */
    .profile-bio {
        text-align: center; /* Align text to the center */
        margin: 0 auto; /* Center the block element itself */
        width: 100%; /* Ensure it takes full width within padding */
        display: block; /* Ensure it behaves as a block element */
        white-space: normal !important; /* Override pre-wrap on mobile */
    }
}
