/* =================================================================
   ROOT VARIABLES & THEME SETTINGS
   ================================================================= */
:root {
    /* Colors - Light Mode */
    --bg-color: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --border-color: #d2d2d7;
    --input-bg: #ffffff;

    /* Brand Colors */
    --accent-color: #007aff; /* Apple Blue */
    --accent-hover: #0071e3;
    --danger-color: #ff3b30; /* Apple Red */
    --success-color: #34c759; /* Apple Green */

    /* Shadows & Radii */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius-sm: 10px;
    --radius-md: 18px;

    /* Typography */
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark Mode Overrides */
body.dark-mode {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --border-color: #38383a;
    --input-bg: #2c2c2e;
    --accent-color: #0a84ff;
    --accent-hover: #409cff;
    --danger-color: #ff453a;
    --success-color: #32d296;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* =================================================================
   GLOBAL RESET & LAYOUT
   ================================================================= */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 40px 20px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased; /* Crisp text on Mac */
    display: flex;
    justify-content: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 640px;
    width: 100%;
}

/* =================================================================
   HEADER & NAVIGATION
   ================================================================= */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

header .page-title {
    font-size: 24px;
    font-weight: 700; /* Bold title */
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.auth-links {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header-welcome {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-right: 8px;
}

/* Button Styles */
.auth-btn {
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 999px; /* Pill shape */
    transition: all 0.2s ease;
}

.register-btn {
    background-color: var(--accent-color);
    color: #ffffff;
}

.register-btn:hover {
    background-color: var(--accent-hover);
}

.login-btn, .logout-btn-style {
    background-color: rgba(0, 122, 255, 0.1);
    color: var(--accent-color);
}

.login-btn:hover {
    background-color: rgba(0, 122, 255, 0.15);
}

.logout-btn-style {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
}

.logout-btn-style:hover {
    background-color: rgba(255, 59, 48, 0.15);
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.dark-mode-toggle:hover {
    opacity: 1;
}

/* =================================================================
   FORMS & INPUTS
   ================================================================= */
.auth-form, .new-message-section form, #message-list li {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.auth-form {
    max-width: 400px;
    margin: 60px auto;
    box-shadow: var(--shadow-md);
    padding: 40px;
}

.auth-form h2 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 30px 0;
    letter-spacing: -0.03em;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px; /* Prevents iOS zoom */
    font-family: inherit;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
    appearance: none;
}

input:focus, textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

textarea {
    height: 100px;
    resize: none;
    margin-bottom: 12px;
}

/* Submit Buttons */
button[type="submit"] {
    background-color: var(--accent-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s, transform 0.1s;
}

/* Special styling for New Message button */
.new-message-section button {
    width: auto;
    float: right;
    padding: 10px 24px;
    font-size: 14px;
    border-radius: 999px;
}

button:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

button:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* =================================================================
   VALIDATION FEEDBACK
   ================================================================= */
.password-hint {
    font-size: 13px;
    margin-top: -10px;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.password-feedback-area {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 5px 0;
    min-height: 25px;
    margin-top: -10px;
    margin-bottom: 15px;
}

.valid-text {
    color: var(--success-color);
}

.invalid-text {
    color: var(--danger-color);
}

.nav-link {
    display: block;
    text-align: center;
    margin-top: 24px;
    color: var(--accent-color);
    text-decoration: none;
    font-size: 14px;
}

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

/* =================================================================
   TIMELINE & MESSAGES
   ================================================================= */
.timeline-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 40px 0 16px 4px;
    color: var(--text-primary);
}

#message-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    position: relative;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    background-color: #e5e5ea;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.display-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.username {
    font-size: 13px;
    color: var(--text-secondary);
}

#message-list li p {
    font-size: 16px;
    line-height: 1.6;
    margin: 0 0 8px 56px;
    color: var(--text-primary);
    word-wrap: break-word;
}

.timestamp {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 56px;
}

.delete-btn {
    position: absolute;
    right: 0;
    top: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    transition: color 0.2s;
    padding: 4px;
}

.delete-btn:hover {
    color: var(--danger-color);
}

/* Clearfix for new message form */
.new-message-section form::after {
    content: "";
    display: table;
    clear: both;
}

/* =================================================================
   PASSWORD TOGGLE (EYE ICON)
   ================================================================= */
.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    padding-right: 40px; /* Space for the eye icon */
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) translateY(-8px); /* Adjust for margin-bottom of input */
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--text-primary);
}

/* Fix vertical alignment if input has margin-bottom */
.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
    margin-bottom: 16px;
}