/* Ephemeral Chat - Mobile First Hacker Style */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Orbitron:wght@700&display=swap');

/* ========== CSS Variables ========== */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111318;
    --bg-tertiary: #1a1d24;
    --accent-green: #00ff41;
    --accent-green-dim: #00cc33;
    --accent-green-glow: rgba(0, 255, 65, 0.25);
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-red: #ff3b5c;
    --text-primary: #e4e4e7;
    --text-secondary: #71717a;
    --border-color: rgba(0, 255, 65, 0.2);
    --bubble-own: rgba(0, 255, 65, 0.1);
    --bubble-other: rgba(0, 212, 255, 0.1);
}

/* ========== Reset & Base ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ========== Container ========== */
.ephemeral-chat-container {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-primary);
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Fullscreen mode */
.ephemeral-chat-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 999999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
}

/* フルスクリーン時のチャットエリア */
.ephemeral-chat-container.fullscreen .ephemeral-chat-area {
    height: 100% !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
}

/* フルスクリーン時のメッセージエリア */
.ephemeral-chat-container.fullscreen .ephemeral-chat-messages {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* フルスクリーン時の入力エリア */
.ephemeral-chat-container.fullscreen .ephemeral-chat-input-area {
    flex-shrink: 0 !important;
    display: block !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Background glow effect */
.ephemeral-chat-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, var(--accent-green-glow) 0%, transparent 40%);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

/* ========== WELCOME SCREEN ========== */
.ephemeral-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    position: relative;
    z-index: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Welcome Header */
.ephemeral-welcome-header {
    text-align: center;
    margin-bottom: 32px;
}

.ephemeral-welcome-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-green);
    letter-spacing: 4px;
    text-shadow: 0 0 30px var(--accent-green-glow);
    margin-bottom: 8px;
}

.ephemeral-welcome-header p {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

/* Tabs */
.ephemeral-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.ephemeral-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}

.ephemeral-tab.active {
    background: var(--accent-green);
    color: #000;
    box-shadow: 0 0 20px var(--accent-green-glow);
}

/* Tab Content */
.ephemeral-tab-content {
    display: none;
    flex: 1;
}

.ephemeral-tab-content.active {
    display: block;
}

/* Form */
.ephemeral-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ephemeral-form-row {
    display: flex;
    gap: 12px;
}

.ephemeral-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ephemeral-form-half {
    flex: 1;
}

.ephemeral-form-group label {
    font-size: 10px;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ephemeral-form-group input,
.ephemeral-form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px; /* Prevent iOS zoom */
    color: var(--text-primary);
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.ephemeral-form-group input::placeholder {
    color: var(--text-secondary);
}

.ephemeral-form-group input:focus,
.ephemeral-form-group select:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--accent-green-glow);
}

.ephemeral-form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2300ff41' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.ephemeral-form-group input[type="text"] {
    text-transform: uppercase;
}

/* Buttons */
.ephemeral-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.ephemeral-btn-primary {
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-dim) 100%);
    color: #000;
    box-shadow: 0 4px 20px var(--accent-green-glow);
}

.ephemeral-btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px var(--accent-green-glow);
}

.ephemeral-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

.ephemeral-btn-secondary:active {
    background: rgba(0, 212, 255, 0.1);
}

.ephemeral-btn-icon {
    font-size: 16px;
}

/* Welcome Footer */
.ephemeral-welcome-footer {
    margin-top: auto;
    padding-top: 24px;
}

.ephemeral-features {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 11px;
    color: var(--text-secondary);
}

.ephemeral-features span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========== CHAT AREA ========== */
.ephemeral-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Chat Header */
.ephemeral-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ephemeral-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ephemeral-status-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ephemeral-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.ephemeral-expiry-display {
    font-size: 10px;
    color: var(--accent-cyan);
}

.ephemeral-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ephemeral-header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 11px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.ephemeral-header-btn:active {
    background: var(--accent-green-glow);
    border-color: var(--accent-green);
}

.ephemeral-room-id-display {
    color: var(--accent-green);
    font-weight: 600;
}

.ephemeral-fullscreen-btn {
    padding: 8px 10px;
    font-size: 16px;
}

/* Messages Area */
.ephemeral-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* System Message */
.ephemeral-system-message {
    text-align: center;
    margin: 16px 0;
}

.ephemeral-system-message span {
    display: inline-block;
    padding: 6px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-purple);
    border-radius: 20px;
    font-size: 10px;
    color: var(--accent-purple);
    letter-spacing: 1px;
}

/* Message */
.ephemeral-message {
    display: flex;
    margin-bottom: 12px;
    animation: slideIn 0.2s ease;
}

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

.ephemeral-message-own {
    justify-content: flex-end;
}

.ephemeral-message-other {
    justify-content: flex-start;
}

.ephemeral-message-content {
    max-width: 80%;
    min-width: 60px;
}

.ephemeral-message-name {
    font-size: 10px;
    color: var(--accent-cyan);
    margin-bottom: 4px;
    padding-left: 4px;
}

.ephemeral-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
}

.ephemeral-message-own .ephemeral-message-bubble {
    background: var(--bubble-own);
    color: var(--accent-green);
    border: 1px solid var(--accent-green-dim);
    border-bottom-right-radius: 4px;
}

.ephemeral-message-other .ephemeral-message-bubble {
    background: var(--bubble-other);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-bottom-left-radius: 4px;
}

.ephemeral-message-time {
    font-size: 9px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

.ephemeral-message-own .ephemeral-message-time {
    text-align: right;
}

/* Image Message */
.ephemeral-message-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    cursor: pointer;
}

.ephemeral-message-bubble.image-bubble {
    padding: 4px;
    background: transparent;
    border: none;
}

/* Input Area */
.ephemeral-chat-input-area {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ephemeral-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ephemeral-input-wrapper {
    flex: 1;
    position: relative;
}

.ephemeral-message-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-family: inherit;
    font-size: 16px;
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    -webkit-appearance: none;
}

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

.ephemeral-message-input:focus {
    outline: none;
    border-color: var(--accent-green);
}

.ephemeral-input-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ephemeral-input-btn:active {
    transform: scale(0.95);
}

.ephemeral-send-btn {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #000;
}

.ephemeral-send-btn:active {
    background: var(--accent-green-dim);
}

/* Image Preview */
.ephemeral-image-preview {
    position: relative;
    margin-bottom: 8px;
    display: inline-block;
}

.ephemeral-image-preview img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 8px;
    border: 2px solid var(--accent-green);
}

.ephemeral-remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--accent-red);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* File Input Hidden */
.ephemeral-file-input {
    display: none;
}

/* ========== MODALS & OVERLAYS ========== */

/* Image Modal */
.ephemeral-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000000;
    padding: 60px 20px 20px;
    cursor: pointer;
}

.ephemeral-image-modal img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    pointer-events: none;
}

.ephemeral-modal-close {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    width: 50px;
    height: 50px;
    background: var(--accent-red);
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000001;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ephemeral-modal-close:active {
    transform: scale(0.9);
    background: #ff0033;
}

/* Expired Overlay */
.ephemeral-expired-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 40px;
    text-align: center;
}

.ephemeral-expired-overlay h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    color: var(--accent-red);
    margin-bottom: 12px;
    text-shadow: 0 0 20px rgba(255, 59, 92, 0.5);
}

.ephemeral-expired-overlay p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* Toast */
.ephemeral-toast {
    position: fixed;
    bottom: max(100px, calc(80px + env(safe-area-inset-bottom)));
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-green);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-green);
    z-index: 1000001;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 20px var(--accent-green-glow);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Loading */
.ephemeral-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.ephemeral-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ephemeral-loading-text {
    font-size: 12px;
    color: var(--accent-green);
    letter-spacing: 2px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ========== DESKTOP STYLES ========== */
@media (min-width: 600px) {
    .ephemeral-chat-container {
        max-width: 480px;
        margin: 20px auto;
        min-height: calc(100vh - 40px);
        border-radius: 16px;
        border: 1px solid var(--border-color);
        box-shadow: 0 0 60px var(--accent-green-glow);
    }
    
    .ephemeral-chat-container.fullscreen {
        max-width: 100vw !important;
        margin: 0 !important;
        min-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    .ephemeral-welcome-header h1 {
        font-size: 36px;
    }
    
    .ephemeral-message-content {
        max-width: 70%;
    }
}

/* ========== VERY SMALL SCREENS ========== */
@media (max-width: 360px) {
    .ephemeral-welcome-header h1 {
        font-size: 24px;
        letter-spacing: 2px;
    }
    
    .ephemeral-tab {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .ephemeral-features {
        gap: 12px;
        font-size: 10px;
    }
}

/* ========== LANDSCAPE MODE ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .ephemeral-welcome {
        padding: 16px;
    }
    
    .ephemeral-welcome-header {
        margin-bottom: 16px;
    }
    
    .ephemeral-welcome-header h1 {
        font-size: 24px;
    }
    
    .ephemeral-form-group input,
    .ephemeral-form-group select {
        padding: 10px 14px;
    }
    
    .ephemeral-btn {
        padding: 12px 20px;
    }
    
    .ephemeral-welcome-footer {
        padding-top: 12px;
    }
}

/* ========== iOS KEYBOARD FIX ========== */
@supports (-webkit-touch-callout: none) {
    .ephemeral-chat-area {
        height: -webkit-fill-available;
    }
}

/* ========== PRINT (disable) ========== */
@media print {
    .ephemeral-chat-container {
        display: none;
    }
}
