/**
 * 13RT.com Stylesheet
 * Mobile-First Shoutbox App
 */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --facebook-blue: #1877F2;
    --white: #FFFFFF;
    --dark-gray: #1C1E21;
    --light-gray: #F0F2F5;
    --error-red: #F02849;
    --border-color: #E4E6EB;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light-gray);
    color: var(--dark-gray);
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Age Gate */
.age-gate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.age-gate-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.age-gate-content h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--dark-gray);
}

.age-gate-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.btn-primary {
    background-color: var(--facebook-blue);
    color: var(--white);
}

.btn-primary:active {
    background-color: #1464D2;
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--light-gray);
    color: var(--dark-gray);
}

.btn-secondary:active {
    background-color: #E4E6EB;
    transform: scale(0.98);
}

/* Nickname Entry */
.nickname-entry {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.nickname-entry-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.nickname-entry-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--dark-gray);
}

#nickname-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#nickname-input,
#settings-nickname-input {
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.2s;
    min-height: 48px;
    -webkit-appearance: none;
}

#nickname-input:focus,
#settings-nickname-input:focus {
    outline: none;
    border-color: var(--facebook-blue);
}

/* Main Shoutbox App */
.shoutbox {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    height: 600px;
    margin: 20px auto;
    background-color: var(--white);
    border: 2px solid var(--facebook-blue);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

/* Header Cell */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: #F8F9FA;
    border-bottom: 2px solid var(--facebook-blue);
    flex-shrink: 0;
    z-index: 10;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--facebook-blue);
    margin: 0;
    letter-spacing: 0.5px;
}

.settings-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--light-gray);
    color: var(--dark-gray);
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.settings-button:active {
    background-color: #E4E6EB;
    transform: scale(0.95);
}

/* Messages Cell */
.messages-area {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--white);
    border-bottom: 2px solid var(--facebook-blue);
    min-height: 0;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: 16px;
    display: flex;
    flex-direction: column-reverse;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-end;
    align-items: stretch;
}

.messages-container::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

.messages-container {
    scrollbar-width: none;
}

.message {
    padding: 12px 16px;
    margin-bottom: 10px;
    background-color: var(--white);
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    border: 1px solid #E4E6EB;
}

.message .nickname {
    font-weight: 600;
    color: var(--facebook-blue);
    margin-right: 6px;
}

.message .content {
    color: var(--dark-gray);
}

/* Input Cell */
.input-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background-color: #F8F9FA;
    flex: 0 0 auto;
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.05);
    min-height: fit-content;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#message-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-family: inherit;
    transition: border-color 0.2s;
    background-color: var(--light-gray);
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

#message-input:focus {
    outline: none;
    border-color: var(--facebook-blue);
    background-color: var(--white);
}

.send-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--facebook-blue);
    color: var(--white);
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 4px rgba(24, 119, 242, 0.2);
}

.send-button:active {
    background-color: #1464D2;
    transform: scale(0.95);
}

.send-button:disabled {
    background-color: #BCC0C4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Error Messages */
.error-message {
    color: var(--error-red);
    font-size: 13px;
    padding: 4px 0;
    min-height: 20px;
    text-align: center;
}

/* Settings Modal */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.settings-content {
    background-color: var(--white);
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.settings-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--dark-gray);
}

#settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.settings-buttons .btn {
    width: 100%;
}

/* Mobile Styles */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
        height: 100vh;
        width: 100vw;
        overflow: hidden;
        position: fixed;
        top: 0;
        left: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .shoutbox {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        margin: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
    }

    .app-header {
        background-color: #F8F9FA;
        border-bottom: 2px solid var(--facebook-blue);
        box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05);
        position: relative;
        z-index: 10;
        flex: 0 0 auto;
        flex-shrink: 0;
        display: flex;
        width: 100%;
    }

    .messages-area {
        background-color: var(--white);
        border-bottom: 2px solid var(--facebook-blue);
        box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05);
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .messages-container {
        padding: 12px;
        padding-bottom: 100px !important; /* Space for fixed input area at bottom */
        justify-content: flex-end;
    }

    .input-area {
        background-color: #F8F9FA !important;
        box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.05);
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        width: 100% !important;
        box-sizing: border-box;
        display: flex !important;
        flex-direction: column;
        border-top: 2px solid var(--facebook-blue);
        padding: 12px 16px !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
}

/* Desktop Styles */
@media (min-width: 769px) {
    .shoutbox {
        max-width: 500px;
        width: 500px;
    }

    .age-gate-buttons {
        flex-direction: row;
        justify-content: center;
    }

    .age-gate-buttons .btn {
        min-width: 120px;
    }
}

/* Prevent text size adjustment on iOS */
@media screen and (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
}
