/**
 * Mobile Event Page CSS
 * ChatGPT iOS App Style - Flexbox Layout with dvh units
 */

/* ================================================
   CSS VARIABLES - ChatGPT Color Palette
   ================================================ */
:root {
    /* Background Colors - White Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-topbar: #ffffff;
    --bg-input: #f4f4f4;
    --bg-message-user: #f4f4f4;
    --bg-message-ai: transparent;
    --bg-pill: #ffffff;

    /* Text Colors - Dark Text */
    --text-primary: #000000;
    --text-secondary: #8e8e93;
    --text-placeholder: #8e8e93;

    /* Accent Colors */
    --accent-green: #10a37f;
    --accent-blue: #0a84ff;

    /* Border Colors - Light Gray */
    --border-color: #e5e5e5;
    --border-light: #d1d1d6;

    /* Layout - Flexbox Layout */
    --topbar-height: 56px;
    --input-area-height: 72px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-top: env(safe-area-inset-top, 0px);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', Roboto, sans-serif;
}

/* ================================================
   RESET & BASE STYLES
   ================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    background-color: var(--bg-primary);
}

body {
    height: 100vh; /* fallback */
    height: 100dvh;
    overflow: hidden;
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================================================
   MAIN CONTAINER - Flexbox Layout
   ================================================ */
.mevent-container {
    height: 100vh; /* fallback */
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ================================================
   TOP BAR - Flex Item (shrink: 0)
   ================================================ */
.mevent-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: var(--topbar-height);
    padding: 0 16px;
    padding-top: var(--safe-area-top);
    background-color: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
}

.topbar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    margin-left: -8px;
    margin-right: 4px;
}

.topbar-back:hover {
    background-color: var(--bg-input);
}

.topbar-back svg {
    width: 24px;
    height: 24px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 40px;
}

.topbar-icon {
    font-size: 20px;
    color: var(--text-primary);
    font-weight: 300;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.topbar-title h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-title .version-indicator {
    color: var(--text-secondary);
    font-size: 14px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ================================================
   CHAT AREA - Flex Item (flex: 1, scrollable)
   ================================================ */
.chat-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column-reverse;  /* 하단부터 시작, 키보드 올라와도 최신 메시지 보임 */
    gap: 8px;
    background-color: var(--bg-primary);
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    align-self: flex-end;
}

.message-ai {
    align-self: flex-start;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-user .message-content {
    background-color: var(--bg-message-user);
    border: 1px solid var(--border-color);
    border-radius: 18px 18px 4px 18px;
}

.message-ai .message-content {
    background-color: var(--bg-message-ai);
    padding: 0;
    padding-top: 10px;
    flex: 1;
}

/* Markdown Content Styles */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    color: #1a202c;
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4 { font-size: 1em; }

.message-content p {
    margin: 8px 0;
}

.message-content code {
    background: linear-gradient(135deg, #e8f4f8 0%, #dce9f0 100%);
    color: #2d5a7b;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Menlo', Consolas, monospace;
    font-size: 0.9em;
    border: 1px solid #c4dce8;
}

.message-content pre.code-block {
    background: linear-gradient(135deg, #f8fafb 0%, #edf2f5 100%);
    border: 1px solid #e0e8ed;
    border-radius: 10px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
}

.message-content pre.code-block code {
    background: transparent;
    border: none;
    padding: 0;
    color: #2d3748;
    font-size: 13px;
    line-height: 1.5;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 0;
    list-style: none;
}

.message-content ul li {
    padding: 4px 0 4px 20px;
    position: relative;
    color: #4a5568;
}

.message-content ul li::before {
    content: '•';
    position: absolute;
    left: 6px;
    color: #48bb78;
    font-weight: bold;
}

.message-content strong {
    color: #1a202c;
    font-weight: 600;
}

.message-content em {
    color: #4a5568;
    font-style: italic;
}

.message-content blockquote {
    border-left: 3px solid #68d391;
    background: linear-gradient(135deg, #f0fff4 0%, #e6f7ef 100%);
    padding: 10px 14px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
    color: #2f855a;
    font-style: italic;
}

.message-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    margin: 16px 0;
}

.message-content a {
    color: #3182ce;
    text-decoration: none;
    border-bottom: 1px solid #bee3f8;
    transition: all 0.2s ease;
}

.message-content a:hover {
    color: #2b6cb0;
    border-bottom-color: #90cdf4;
}

/* AI Avatar */
.ai-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* AI Avatar Image */
.ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ================================================
   INPUT AREA - Flex Item (shrink: 0)
   ================================================ */
.input-area {
    flex-shrink: 0;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    background-color: var(--bg-primary);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 8px 8px 8px 12px;
}

.attach-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attach-btn:hover {
    color: var(--text-primary);
}

.message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-family);
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 24px;
    outline: none;
}

.message-input::placeholder {
    color: var(--text-placeholder);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #000000;
    border: none;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background-color: #333333;
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.send-btn.active {
    background-color: #000000;
}

/* ================================================
   RESPONSIVE ADJUSTMENTS
   ================================================ */
@media (max-width: 480px) {
    .topbar-title h1 {
        font-size: 15px;
    }

    .message-content {
        font-size: 15px;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --input-area-height: 60px;
    }

    .input-area {
        padding: 8px 16px;
    }
}

/* ================================================
   SCROLLBAR STYLING
   ================================================ */
.chat-area::-webkit-scrollbar {
    width: 4px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 2px;
}

/* ================================================
   UTILITY CLASSES
   ================================================ */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ================================================
   TOPBAR LOGIN BUTTON & DOMAIN - v3 Landing
   ================================================ */
.topbar-domain {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.topbar-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: white;
    background: #6366f1;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.topbar-login-btn:hover {
    opacity: 0.9;
}

/* Game Creator 로그인 버튼 (초록색) */
.game-login-btn {
    background: #10a37f;
}

/* Friend Maker 로그인 버튼 (보라색) */
.fmaker-login-btn {
    background: #6366f1;
}

/* ================================================
   TOPBAR PROFILE - Logged in user display
   ================================================ */
.topbar-profile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(16, 163, 127, 0.1);
    flex-shrink: 0;
}

.topbar-profile .profile-name {
    font-size: 13px;
    font-weight: 600;
    color: #10a37f;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Make profile clickable */
.topbar-profile[role="button"],
.topbar-profile.profile-btn {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.topbar-profile[role="button"]:hover,
.topbar-profile.profile-btn:hover {
    opacity: 0.8;
}

/* ================================================
   LOGOUT MODAL
   ================================================ */
.logout-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.logout-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 24px;
    min-width: 280px;
    max-width: 90%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    animation: modalSlideUp 0.2s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logout-modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.logout-user-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.logout-modal-body {
    margin-bottom: 12px;
}

.logout-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    background: #ef4444;
    color: white;
    cursor: pointer;
    transition: background 0.2s ease;
}

.logout-btn:hover {
    background: #dc2626;
}

.logout-modal-close {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    background: #f4f4f4;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s ease;
}

.logout-modal-close:hover {
    background: #e5e5e5;
}

/* ================================================
   ZERO MINUTE BANNER - v3 Landing
   ================================================ */
.zero-minute-banner {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 16px;
    margin: 0 0 12px 0;
    width: 100%;
    box-sizing: border-box;
}

.banner-content {
    margin-bottom: 12px;
}

.banner-text {
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--text-primary);
}

.banner-text strong {
    font-weight: 600;
}

.banner-domain {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    color: #6b7280;
}

.banner-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.banner-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.banner-btn:hover:not(.disabled) {
    opacity: 0.9;
}

.banner-btn.kakao {
    background: #fee500;
    color: #000;
}

.banner-btn.send {
    background: #10a37f;
    color: white;
}

.banner-btn.copy {
    background: #e2e8f0;
    color: #1a1a2e;
}

.banner-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Game Creator 배너 (파란색 계열) */
.game-banner {
    background: #eff6ff;
    border-color: #3b82f6;
}

/* Friend Maker 배너 (노란색 계열) */
.fmaker-banner {
    background: #fffbeb;
    border-color: #f59e0b;
}
