/* --- DropIt Messenger Styles (Combined - v7 Video Drops) --- */

:root {
    /* Color Palette */
    --bg-color: #18191a;
    --header-bg: #242526;
    --input-bg: #242526;
    --messages-bg: #18191a;
    --panel-bg: #2d2e30; /* Slightly lighter for panels like setup */
    --text-color: #e4e6eb;
    --text-muted: #b0b3b8;
    --border-color: #3a3b3c;
    --accent-color: #0084ff; /* FB Messenger Blue */
    --accent-hover: #006fff;
    --sent-bubble-bg: var(--accent-color);
    --received-bubble-bg: #3a3b3c; /* Default for received, JS might override */
    --system-text-color: var(--text-muted);
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --muted-color: #6c757d; /* For unavailable buttons */

    /* Typography */
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* Layout Dimensions */
    --header-height: 50px;
    --input-area-height: 60px;
    --presets-height: 45px; /* Height of optional presets bar */
    --typing-indicator-height: 20px; /* Height of typing indicator bar */

    /* Z-Indexes */
    --z-index-messages: 1;
    --z-index-typing: 4;
    --z-index-presets: 5;
    --z-index-header-input: 10;
    --z-index-overlay: 100; /* For status messages */
}

/* --- Global Reset & Body --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100%;
    width: 100%;
    overflow: hidden; /* Prevent body scrolling, container will scroll */
    display: flex;
    margin: 0;
}

/* --- Main Application Container --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%; /* Full viewport height */
    width: 100%;
    max-width: 800px; /* Max width for larger screens */
    margin: 0 auto; /* Center on larger screens */
    background-color: var(--messages-bg);
    position: relative; /* Establish positioning context */
}

/* --- Header --- */
.chat-header {
    display: flex;
    align-items: center;
    padding: 0 10px;
    height: var(--header-height);
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    position: fixed; /* Keep header fixed at the top */
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-index-header-input);
    max-width: 800px; /* Match app container */
    margin: 0 auto; /* Center fixed header */
}

.chat-header .back-btn {
    background: none; border: none; color: var(--accent-color); font-size: 1.2em; padding: 5px; cursor: pointer; flex-shrink: 0; margin-right: 5px;
}
.chat-header .chat-title {
    font-weight: 600; font-size: 1.0em; flex-grow: 1; text-align: center; padding: 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header .hands-free-toggle {
    background: none; border: none; color: var(--text-muted); font-size: 1.3em; padding: 0 5px; cursor: pointer; transition: color 0.2s ease; flex-shrink: 0; margin-left: 5px;
}
.chat-header .hands-free-toggle:hover { color: var(--accent-color); }
.chat-header .hands-free-toggle.active { color: var(--success-color); }
.chat-header .hands-free-toggle.unavailable { color: var(--muted-color); opacity: 0.5; cursor: not-allowed; }
.chat-header .status-indicator {
    width: 10px; height: 10px; border-radius: 50%; background-color: var(--text-muted); transition: background-color 0.3s ease; flex-shrink: 0; margin-left: 5px;
}
.chat-header .status-indicator.connected { background-color: var(--success-color); }
.chat-header .status-indicator.error { background-color: var(--error-color); }
.chat-header .status-indicator.pending { background-color: var(--warning-color); }


/* --- Message Area --- */
.chat-messages {
    flex-grow: 1; /* Take remaining vertical space */
    overflow-y: auto; /* Allow vertical scrolling for messages */
    padding: 15px 10px;
    display: flex;
    flex-direction: column; /* Stack message containers */
    /* Padding accounts for fixed header and input area. JS adjusts for presets/typing */
    padding-top: calc(var(--header-height) + 15px);
    /* Base padding-bottom assumes NO presets/typing indicator visible */
    padding-bottom: calc(var(--input-area-height) + 15px);
    transition: padding-bottom 0.2s ease-in-out;
    position: relative;
    z-index: var(--z-index-messages);
}

/* Message Container (for alignment) */
.message-container {
    display: flex;
    margin-bottom: 8px; /* Space between distinct message groups/bubbles */
    width: 100%;
}
.message-container.align-left { justify-content: flex-start; }
.message-container.align-right { justify-content: flex-end; }
.message-container.align-center { justify-content: center; }

/* Message Bubbles (Base for Text & Video) */
.chat-message {
    padding: 8px 12px;
    border-radius: 18px;
    max-width: 75%; /* Max width of bubble relative to container */
    font-size: 0.95em;
    line-height: 1.4;
    word-wrap: break-word; /* Wrap long words */
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* Alignment-specific corner rounding */
.align-left .chat-message { border-bottom-left-radius: 5px; }
.align-right .chat-message { border-bottom-right-radius: 5px; }

/* Sender Name Style (inside received messages) */
.chat-message .sender-name {
    font-size: 0.8em; font-weight: 600; margin-bottom: 3px; opacity: 0.7; color: inherit; max-width: calc(100% - 50px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Timestamp Style (inside user messages) */
.chat-message .timestamp {
    font-size: 0.7em; margin-top: 4px; text-align: right; opacity: 0.7; color: inherit; align-self: flex-end; flex-shrink: 0;
}

/* Sent Bubble Styles */
.chat-message.sent { background-color: var(--sent-bubble-bg); color: white; }

/* Received Bubble Styles */
/* JS sets background-color and color based on user */

/* System Message Styles */
.chat-message.system {
    background-color: transparent !important; color: var(--system-text-color) !important; font-size: 0.75em; font-style: italic; text-align: center; max-width: 90%; padding: 5px 0; box-shadow: none; border-radius: 0;
}
.chat-message.system span { background-color: rgba(40, 40, 40, 0.6); padding: 2px 8px; border-radius: 10px; display: inline-block; }


/* --- Video Drop Specific Styles --- */
.message-container video {
    max-width: 100%; /* Video width constrained by parent bubble's max-width */
    max-height: 300px; /* Limit video height */
    border-radius: 10px; /* Match bubble corners */
    display: block; /* Prevent extra space below */
    background-color: #000; /* Black background while loading/if controls only */
    margin-bottom: 5px; /* Space before caption */
}

/* Caption for Video/Audio Drops */
.media-caption {
    font-size: 0.8em;
    /* Use inherit or a specific muted color */
    color: inherit; /* Inherit from bubble text color */
    opacity: 0.8;
    margin-top: 3px; /* Small space above caption if needed */
    text-align: left; /* Ensure caption aligns left within bubble */
}
/* Adjust caption color for sent messages (white text) */
.chat-message.sent .media-caption {
    color: rgba(255, 255, 255, 0.8);
}


/* --- Optional Presets Area --- */
.chat-presets-container {
    position: fixed; bottom: var(--input-area-height); left: 0; right: 0; height: var(--presets-height); background-color: var(--input-bg); border-top: 1px solid var(--border-color); overflow-x: auto; overflow-y: hidden; white-space: nowrap; z-index: var(--z-index-presets); max-width: 800px; margin: 0 auto; display: none; /* Hidden by default */ transition: transform 0.2s ease-in-out;
}
.chat-presets-container.visible { display: block; }
.chat-presets { display: inline-flex; gap: 8px; padding: 8px 10px; align-items: center; height: 100%; }
.chat-presets button { background-color: rgba(255, 255, 255, 0.08); border: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.8em; padding: 5px 12px; border-radius: 15px; cursor: pointer; transition: all 0.2s ease; flex-shrink: 0; white-space: nowrap; }
.chat-presets button:hover { background-color: rgba(255, 255, 255, 0.15); color: var(--text-color); border-color: var(--accent-color); }

/* --- Typing Indicator Area --- */
.typing-indicator-area {
    height: var(--typing-indicator-height); padding: 0 12px; flex-shrink: 0; display: flex; align-items: center; overflow: hidden; position: fixed; bottom: var(--input-area-height); left: 0; right: 0; max-width: 800px; margin: 0 auto; background: var(--input-bg); border-top: 1px solid var(--border-color); z-index: var(--z-index-typing); opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease, bottom 0.2s ease-in-out;
}
.typing-indicator-area.visible { opacity: 1; visibility: visible; }
/* Adjust position if presets are ALSO visible */
.chat-presets-container.visible + .typing-indicator-area { bottom: calc(var(--input-area-height) + var(--presets-height)); }
#typing-indicator-text { font-size: 0.8em; color: var(--text-muted); font-style: italic; animation: typing-fade 1.5s infinite ease-in-out; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes typing-fade { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }


/* --- Input Area --- */
.chat-input-area {
    display: flex; align-items: center; padding: 10px 10px; height: var(--input-area-height); background-color: var(--input-bg); border-top: 1px solid var(--border-color); flex-shrink: 0; position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-index-header-input); max-width: 800px; margin: 0 auto; gap: 8px; /* Add gap between elements */
}
.chat-input-area input {
    flex-grow: 1; padding: 10px 15px; border: none; background-color: var(--received-bubble-bg); color: var(--text-color); border-radius: 20px; outline: none; font-size: 0.95em; height: 40px;
}
.chat-input-area input:disabled { background-color: #444; cursor: not-allowed; opacity: 0.6; }
.chat-input-area button {
    background-color: var(--accent-color); color: white; border: none; border-radius: 50%; width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background-color 0.2s ease; font-size: 1.1em; /* Icon size */
}
.chat-input-area button:hover { background-color: var(--accent-hover); }
.chat-input-area button:disabled { background-color: #555; cursor: not-allowed; opacity: 0.6; }
/* Specific style for record button if needed, e.g., different color */
#record-video-btn {
    /* background-color: #ff3b30; */ /* Example: Red color for record */
    /* &:hover { background-color: #d92c23; } */
}

/* --- Video Record/Preview Modal --- */
.video-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-index-overlay); /* Ensure it's above other elements */
    opacity: 1;
    transition: opacity 0.3s ease;
}

.video-modal-container.hidden {
    opacity: 0;
    pointer-events: none; /* Prevent interaction when hidden */
}

.video-modal-content {
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 500px; /* Limit max width */
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#video-modal-title {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.2em;
}

#video-preview {
    width: 100%;
    max-height: 60vh; /* Limit video height */
    background-color: #000;
    border-radius: 8px;
    margin-bottom: 15px;
    display: block;
}

.video-controls {
    display: flex;
    justify-content: space-around; /* Space out buttons */
    width: 100%;
    margin-top: 10px;
}
.video-controls.hidden {
    display: none;
}

.modal-button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: white;
    display: inline-flex; /* Align icon and text */
    align-items: center;
    gap: 8px; /* Space between icon and text */
}
.modal-button i {
    font-size: 1.1em;
}

.modal-button.send { background-color: var(--accent-color); }
.modal-button.send:hover { background-color: var(--accent-hover); }
.modal-button.discard { background-color: var(--error-color); }
.modal-button.discard:hover { background-color: #c82333; }


.modal-close-btn {
    position: absolute;
    top: 5px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.8em;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}
.modal-close-btn:hover {
    color: var(--text-color);
}

/* --- Status Message Overlay (Adjusted) --- */
#status-overlay {
    position: fixed;
    /* Position it below the header */
    top: calc(var(--header-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 123, 255, 0.8); /* Default info color */
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    z-index: calc(var(--z-index-overlay) - 1); /* Below modal */
    display: none;
    font-size: 0.9em;
    transition: opacity 0.3s ease;
    opacity: 0; /* Start hidden */
}
#status-overlay.visible {
    display: block;
    opacity: 1;
}

/* --- Desktop Adjustments (Optional) --- */
@media (min-width: 768px) {
    .chat-messages::-webkit-scrollbar { width: 6px; }
    .chat-messages::-webkit-scrollbar-thumb { background-color: #4e4f50; border-radius: 3px; }
    .chat-messages::-webkit-scrollbar-track { background-color: transparent; }
}