/* === Base Reset & Variables === */
:root {
    --primary: #1D9E75;
    --primary-dark: #0F6E56;
    --primary-light: #5DCAA5;
    --accent: #085041;
    --bg: #F7F8F7;
    --bg-card: #FFFFFF;
    --text: #2C2C2A;
    --text-light: #555550;
    --text-muted: #888780;
    --border: #E2E0D8;
    --error: #E53E3E;
    --mediator-bg: #E1F5EE;
    --intake-bg: #F0FFF4;
    --pale: #E1F5EE;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Navbar === */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.nav-logo-mark {
    flex-shrink: 0;
}

.nav-wordmark {
    font-size: 1.25rem;
    font-weight: 300;
    letter-spacing: 0.25em;
    color: var(--text);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-links a { color: var(--text); text-decoration: none; }
.nav-user { color: var(--text-light); font-size: 0.9rem; }

/* === Layout === */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-lg { padding: 0.75rem 2rem; font-size: 1.1rem; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.9rem; }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}
.form-group textarea { resize: vertical; }
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* === Auth === */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 { margin-bottom: 1.5rem; }

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 2.5rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    display: flex;
    align-items: center;
}

.password-toggle:hover {
    color: var(--text);
}
.auth-toggle { text-align: center; margin-top: 1rem; font-size: 0.9rem; }
.auth-toggle a { color: var(--primary); }

.error-msg {
    background: #FFF5F5;
    color: var(--error);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* === Landing === */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
}

.hero-logo {
    margin-bottom: 1.5rem;
}

.hero h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--text);
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0 3rem;
}

.feature-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.feature-card h3 { margin-bottom: 0.5rem; color: var(--accent); }
.feature-card p { color: var(--text-light); font-size: 0.95rem; }

.how-it-works { text-align: center; padding: 2rem 0; }
.how-it-works h2 { margin-bottom: 2rem; }

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.step { padding: 1rem; }
.step-number {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.step h3 { margin-bottom: 0.5rem; }
.step p { color: var(--text-light); font-size: 0.9rem; }

/* === Dashboard === */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.session-list { display: flex; flex-direction: column; gap: 1rem; }

.session-card {
    display: block;
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s;
}
.session-card:hover { box-shadow: var(--shadow-lg); }

.session-card-wrapper {
    position: relative;
}

.session-card-wrapper .btn-delete {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: var(--error);
    border-color: var(--error);
    background: var(--bg-card);
    opacity: 0;
    transition: opacity 0.15s;
}

.session-card-wrapper:hover .btn-delete { opacity: 1; }
.session-card-wrapper .btn-delete:hover { background: #FFF5F5; }

.session-card-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.session-card h3 { margin-bottom: 0.25rem; }
.session-date { color: var(--text-muted); font-size: 0.85rem; }

.session-type-badge {
    display: inline-block;
    background: var(--mediator-bg);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.session-status {
    font-size: 0.8rem;
    font-weight: 500;
}
.session-status.active { color: var(--accent); }
.session-status.closed { color: var(--text-muted); }

.empty-state { text-align: center; color: var(--text-muted); padding: 3rem 0; }
.loading { text-align: center; color: var(--text-muted); padding: 2rem 0; }

/* === Modal === */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 { margin-bottom: 1.5rem; }

.welcome-modal-content {
    max-width: 550px;
    line-height: 1.7;
}

.welcome-modal-content p {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 0.95rem;
}

.welcome-topic {
    background: var(--mediator-bg);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.welcome-tips {
    background: var(--bg);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.welcome-tips strong {
    display: block;
    margin-bottom: 0.5rem;
}

.welcome-tips ul {
    margin: 0;
    padding-left: 1.25rem;
}

.welcome-tips li {
    margin-bottom: 0.25rem;
    color: var(--text-light);
}

/* === Invite Card === */
.invite-card {
    background: var(--intake-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    text-align: center;
}

.invite-link-row {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.invite-link-row input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

/* === Invite Banner (Session Room) === */
.invite-banner {
    background: var(--intake-bg);
    border: 1px solid #C6F6D5;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.invite-banner-content strong {
    color: var(--text);
}

.invite-banner .invite-link-row {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.participant-status {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.participant-status.waiting {
    color: #B7791F;
    background: #FEFCBF;
}

.participant-status.joined {
    color: #276749;
    background: #C6F6D5;
}

/* === Mediation Room === */
.mediation-room {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.room-actions { display: flex; gap: 0.5rem; align-items: center; }

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    max-width: 80%;
}

.message-mediator {
    background: var(--mediator-bg);
    align-self: flex-start;
    max-width: 90%;
}

.message-self {
    background: var(--accent);
    color: white;
    align-self: flex-end;
}

.message-other {
    background: #E6F4F1;
    align-self: flex-start;
    max-width: 80%;
}

.message-other .message-author {
    color: #2B7A6B;
}

.message-other .message-time {
    color: var(--text-muted);
}

.message-intake {
    background: var(--intake-bg);
    align-self: flex-start;
    border: 1px dashed var(--border);
    max-width: 90%;
}

.message-author {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    color: var(--primary-dark);
}

.message-content { white-space: pre-wrap; line-height: 1.5; }
.message-time { font-size: 0.75rem; opacity: 0.7; margin-top: 0.25rem; text-align: right; }

.mediator-welcome {
    background: var(--mediator-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    line-height: 1.6;
}

/* === Message Input === */
.message-input-area {
    margin-top: 1rem;
    flex-shrink: 0;
}

.message-input-area form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.message-input-area textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
}

.message-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* === Summary Panel === */
.summary-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 480px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 12px rgba(0,0,0,0.1);
    z-index: 200;
    overflow: hidden;
}

body.summary-open {
    overflow: hidden;
}

body.summary-open .container {
    margin-right: 490px;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.summary-content {
    position: absolute;
    top: 56px;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: scroll;
    padding: 1.5rem;
}

.summary-text {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

/* === Error Page === */
.error-page {
    text-align: center;
    padding: 4rem 0;
}

.error-page h1 { font-size: 2rem; margin-bottom: 1rem; }
.error-page p { color: var(--text-light); margin-bottom: 2rem; }

/* === Responsive === */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .navbar { padding: 0.75rem 1rem; }
    .hero h1 { font-size: 1.8rem; }
    .hero-subtitle { font-size: 1rem; }
    .message { max-width: 90%; }
    .message-mediator, .message-intake { max-width: 95%; }

    .summary-panel {
        width: 100%;
        left: 0;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
}
