/* ===========================
   Daily Chat - Dark Modern Theme
   =========================== */

/* CSS Variables */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2937;
    --accent-primary: #e94560;
    --accent-secondary: #0f3460;
    --text-primary: #f1f1f1;
    --text-secondary: #a0a0a0;
    --text-muted: #6b7280;
    --border-color: #2d3748;
    --success: #10b981;
    --error: #ef4444;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   ENTRANCE PAGE
   =========================== */

.entrance-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.entrance-container {
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

.entrance-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 48px 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
}

.entrance-header {
    text-align: center;
    margin-bottom: 40px;
}

.entrance-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.entrance-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 400;
}

.entrance-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 15px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    outline: none;
}

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

.form-input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.entrance-button {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
}

.entrance-button:hover {
    background: #d93a52;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(233, 69, 96, 0.3);
}

.entrance-button:active {
    transform: translateY(0);
}

/* ===========================
   CHAT PAGE
   =========================== */

.chat-page {
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.room-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.user-count-label {
    color: var(--text-secondary);
}

.user-count {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 16px;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    overflow: hidden;
    background: var(--bg-primary);
}

.message-area {
    height: 100%;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar */
.message-area::-webkit-scrollbar {
    width: 8px;
}

.message-area::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

.message-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Message Styles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    animation: messageSlideIn 0.3s ease;
}

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

/* Other's messages - left aligned */
.message {
    align-self: flex-start;
}

.message-sender {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.message-content {
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 15px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    align-self: flex-start;
}

/* My messages - right aligned */
.message.mine {
    align-self: flex-end;
}

.message.mine .message-sender {
    display: none;
}

.message.mine .message-content {
    background: var(--accent-primary);
    color: white;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.message.mine .message-time {
    align-self: flex-end;
}

/* System messages - centered */
.message.system {
    align-self: center;
    max-width: 100%;
    text-align: center;
}

.message.system .message-sender {
    display: none;
}

.message.system .message-content {
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 16px;
}

.message.system .message-time {
    display: none;
}

/* Encrypted/failed decryption messages */
.message-content.encrypted {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-style: italic;
    border: 1px dashed var(--border-color);
}

.message.mine .message-content.encrypted {
    background: rgba(233, 69, 96, 0.2);
    border-color: var(--accent-primary);
}

/* Footer - Input Area */
.chat-footer {
    padding: 20px 32px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.message-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    min-height: 48px;
    max-height: 120px;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-primary);
    resize: none;
    overflow-y: auto;
    transition: all 0.3s ease;
    outline: none;
}

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

.message-input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.message-input::-webkit-scrollbar {
    width: 6px;
}

.message-input::-webkit-scrollbar-track {
    background: transparent;
}

.message-input::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.send-button {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-button:hover {
    background: #d93a52;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(233, 69, 96, 0.3);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* ===========================
   IMAGE MESSAGES
   =========================== */

.message-image {
    padding: 4px !important;
    background: var(--bg-card) !important;
    overflow: hidden;
}

.message.mine .message-image {
    background: var(--accent-primary) !important;
}

.message-image img {
    display: block;
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.message-image img:hover {
    opacity: 0.85;
}

/* Drop Overlay */
.chat-main {
    position: relative;
}

.drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(233, 69, 96, 0.15);
    backdrop-filter: blur(4px);
    border: 3px dashed var(--accent-primary);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
}

.drop-overlay.active {
    display: flex;
}

.drop-overlay-content {
    text-align: center;
}

.drop-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.drop-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-primary);
}

/* Image Viewer (Full Screen) */
.image-viewer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.image-viewer.active {
    display: flex;
}

.image-viewer img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 768px) {
    .chat-header {
        padding: 16px 20px;
    }

    .room-name {
        font-size: 20px;
    }

    .message-area {
        padding: 16px 20px;
    }

    .message {
        max-width: 80%;
    }

    .chat-footer {
        padding: 16px 20px;
    }

    .entrance-card {
        padding: 36px 28px;
    }

    .entrance-title {
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 90%;
    }

    .message-input-container {
        flex-direction: column;
        gap: 8px;
    }

    .send-button {
        width: 100%;
    }
}
