/* ==========================================
   1. FONTS & THEME VARIABLES (COLORS)
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

:root {
    /* Main Background Colors */
    --bg-color: #ffffff;
    --primary-color: #ffb6c1; /* Soft romantic pink */
    --hover-primary: #ff9fb4; /* Slightly darker pink for hover effects */
    --secondary-color: #e6e6fa; /* Light romantic purple/lavender */
    --hover-secondary: #d8d8fa;

    /* Text Colors */
    --text-dark: #4a4a4a;
    --text-light: #ffffff;

    /* Layout Style Tokens */
    --shadow: 0 8px 20px rgba(255, 182, 193, 0.3);
    --shadow-hover: 0 12px 25px rgba(255, 182, 193, 0.5);
    --border-radius: 20px;
    --btn-radius: 30px;
    --transition: all 0.3s ease;
}

/* ==========================================
   2. GENERAL RESET & BODY (Apply to everything)
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
}

body {
    background-color: var(--bg-color);
    /* Soft gradient background */
    background-image: radial-gradient(circle at top right, #fff0f5, #ffffff);
    color: var(--text-dark);
    
    /* Center the app window on screen */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
}

/* The invisible box holding the entire app */
.app-container {
    width: 100%;
    max-width: 500px;
    height: 95vh;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05); /* Soft drop shadow */
    
    /* Flexible column layout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 2px solid #fff0f5; /* Cute border */
}

/* ==========================================
   3. TOP SECTION (Title and Status)
   ========================================== */
.top-section {
    padding: 15px 20px;
    /* Cute diagonal gradient */
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.website-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

.status-indicator {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 12px;
    border-radius: 15px;
}

/* The red/green connection light */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff6b6b; /* Red = disconnected */
    margin-right: 8px;
    transition: var(--transition);
}
.status-dot.connected { 
    background-color: #2ed573; /* Green = connected */
}

/* ==========================================
   4. THE CODE POPUP MODAL
   ========================================== */
.modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 40px);
    background: #fff;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 20;
    text-align: center;
    border: 2px solid var(--primary-color);
}

.modal h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

/* Helper to easily hide things */
.hidden { display: none !important; }

textarea {
    width: 100%;
    height: 80px;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    padding: 10px;
    resize: none; /* Don't allow resizing */
    font-size: 0.8rem;
    margin: 10px 0;
    outline: none;
    transition: var(--transition);
}
textarea:focus { border-color: var(--primary-color); }

/* Buttons */
.btn {
    border: none;
    padding: 10px 20px;
    border-radius: var(--btn-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    color: #fff;
}

.btn-primary { background: var(--primary-color); }
.btn-primary:hover { background: var(--hover-primary); box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.btn-secondary { background: var(--secondary-color); color: var(--text-dark); }
.btn-secondary:hover { background: var(--hover-secondary); box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.btn-small { padding: 5px 15px; font-size: 0.8rem; background: var(--secondary-color); color: #333; margin-bottom: 10px;}


/* ==========================================
   5. VIDEO SCREENS (Middle Area)
   ========================================== */
.middle-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 15px;
    position: relative;
    background: #fffafa;
    overflow-y: auto;
}

.video-container {
    position: relative;
    width: 100%;
    flex: 1;
    background: #e0e0e0; /* Grey when no video */
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: var(--transition);
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Fill the box without stretching */
}

/* Mirror the local camera view so it looks like a real mirror */
.mirrored {
    transform: scaleX(-1);
}

/* "Me" / "Partner" Labels on video */
.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Show cute pink border when camera is on */
.partner-video-container.active, .my-video-container.active {
    border: 3px solid var(--primary-color);
}


/* ==========================================
   6. CONTROLS (Camera, Mic, Screen buttons)
   ========================================== */
.media-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 15px;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
    flex-wrap: wrap;
    align-items: center;
}

/* Circular Icon Buttons */
.btn-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: var(--secondary-color);
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(230, 230, 250, 0.8);
}

.btn-icon:hover:not([disabled]) {
    transform: translateY(-2px) scale(1.05); /* Bounce up softly when hovered */
    background: var(--hover-secondary);
}

/* When a button is clicked ON */
.btn-icon.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow);
}

/* When a button cannot be clicked yet */
.btn-icon[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f0f0f0;
}

/* End Call button is red */
.btn-danger { background: #ff6b6b; color: white; }
.btn-danger:hover:not([disabled]) { background: #ff5252; box-shadow: 0 4px 10px rgba(255, 107, 107, 0.4); }

.call-timer {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-left: auto; /* push to the right side */
}


/* ==========================================
   7. TEXT CHAT AREA (Bottom Area)
   ========================================== */
.bottom-section {
    display: flex;
    flex-direction: column;
    padding: 0;
    max-height: 40vh; /* Don't let chat take up entire screen */
    background: #fff;
    border-top: 2px solid #fff0f5;
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto; /* Adds a scrollbar if too many messages */
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 150px;
}

.chat-placeholder {
    margin: auto;
    color: #ccc;
    font-style: italic;
    font-size: 0.9rem;
}

/* Chat Bubbles */
.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 0.95rem;
    position: relative;
    animation: fadeIn 0.3s ease; /* Fade in animation */
    word-wrap: break-word;
}

.msg-mine {
    background: var(--primary-color);
    color: #fff;
    align-self: flex-end; /* Push to right side */
    border-bottom-right-radius: 5px; /* cute speech bubble tip */
}

.msg-partner {
    background: var(--secondary-color);
    color: var(--text-dark);
    align-self: flex-start; /* Push to left side */
    border-bottom-left-radius: 5px; /* cute speech bubble tip */
}

.msg-sys {
    background: #f0f0f0; /* Grey for system messages */
    color: #888;
    align-self: center;
    border-radius: 10px;
    font-size: 0.8rem;
    padding: 5px 10px;
}

.msg-time {
    display: block;
    font-size: 0.65rem;
    margin-top: 5px;
    opacity: 0.8;
}

.typing-indicator {
    padding: 0 15px 10px;
    font-size: 0.8rem;
    color: #aaa;
    font-style: italic;
    height: 20px;
}

/* Text Input Bar */
.chat-input-area {
    display: flex;
    padding: 10px 15px;
    gap: 10px;
    background: #fff0f5;
    align-items: center;
}

#message-input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 0.95rem;
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05); /* inner shadow */
}

.btn-icon-small {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.btn-icon-small:hover { transform: scale(1.1); }

.btn-send {
    background: var(--primary-color);
    color: #fff;
    padding: 10px 15px;
    border-radius: 20px;
    font-weight: bold;
}
.btn-send[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Emoji List popup */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    left: 15px;
    background: #fff;
    border-radius: 15px;
    padding: 10px;
    box-shadow: var(--shadow-hover);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    width: 200px;
    z-index: 50;
    border: 1px solid var(--secondary-color);
}

.emoji-picker span {
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.emoji-picker span:hover {
    transform: scale(1.2);
}

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

/* ==========================================
   8. RESPONSIVE / MOBILE SIZING
   ========================================== */
@media (max-height: 700px) {
    /* If screen is short, shrink the middle a bit to fit chat */
    .middle-section { min-height: 200px; }
    textarea { height: 60px; }
}
