/* --- START OF FILE static/css/style.css --- */

/* VARIABLES */
:root {
    --bg-color: #f0f2f5;
    --mica-bg: #ffffff;
    --surface-layer: #ffffff;
    --accent: #0078d4;
    --accent-hover: #0067c0;
    --text-main: #1a1a1a;
    --text-muted: #5f5f5f;
    --text-inverse: #ffffff;
    --border: #e0e0e0;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* RESET */
* { box-sizing: border-box; outline: none; }
body {
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* App-like feel */
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- AUTH / CENTERED PAGES (Login, Forms) --- */
.center-box {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #eef2f3 0%, #8e9eab 100%); /* Subtle gradient */
}

.form-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px); /* Glass effect */
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255,255,255,0.5);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-card h2 { margin-top: 0; font-size: 24px; color: var(--accent); }
.form-card label { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: block; color: var(--text-muted); }
.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 14px;
    transition: border 0.2s;
}
.form-card input:focus { border-color: var(--accent); }

/* BUTTONS */
.btn-primary {
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
    text-align: center;
    display: inline-block;
}
.btn-primary:hover { background: var(--accent-hover); }

/* --- APP LAYOUT (Chat & Admin) --- */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: white;
    position: relative;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: 60px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 18px;
    color: var(--accent);
    background: white;
}

.room-list { flex: 1; overflow-y: auto; padding: 10px; }

.room-item {
    padding: 10px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-main);
    transition: background 0.1s;
}
.room-item:hover { background: #e9ecef; }
.room-item.active { background: #e0f2fe; color: var(--accent); }

.avatar-circle {
    width: 36px; height: 36px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    margin-right: 12px;
    font-weight: 600; color: #64748b;
    font-size: 14px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

/* CHAT AREA */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    width: 100%;
    min-width: 0; /* Fix flexbox text overflow */
}

.chat-header {
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    z-index: 40;
}

/* MOBILE TOGGLE BUTTON */
.mobile-menu-btn {
    display: none; /* Hidden on desktop */
    background: none; border: none;
    margin-right: 12px; cursor: pointer;
    padding: 4px; color: var(--text-main);
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f1f5f9; /* Chat bg */
}

/* MESSAGE BUBBLES */
.msg-row { display: flex; width: 100%; margin-bottom: 4px; }
.msg-row.mine { justify-content: flex-end; }

.msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    word-wrap: break-word;
}

.msg-row.mine .msg-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.msg-row.mine .msg-bubble a { color: #fff; text-decoration: underline; }

.msg-row.other .msg-bubble {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

/* --- FIXED CHAT MEDIA & ACTIONS (IMAGES, FILES, BUTTONS) --- */

/* 1. Images */
.msg-img {
    display: block;
    max-width: 100%;       /* Prevent overflowing the bubble */
    height: auto;          /* Maintain aspect ratio */
    max-height: 300px;     /* Cap height */
    border-radius: 8px;
    margin-top: 5px;
    margin-bottom: 5px;
    object-fit: cover;
    cursor: pointer;
}

/* 2. File Attachments */
.msg-file {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.06);
    padding: 10px;
    border-radius: 8px;
    margin: 6px 0;
    text-decoration: none !important;
    color: inherit;
    font-weight: 500;
    font-size: 13px;
    border: 1px solid rgba(0,0,0,0.05);
    transition: background 0.2s;
}

/* File style for 'My' messages */
.msg-row.mine .msg-file {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}
.msg-row.mine .msg-file:hover { background: rgba(255, 255, 255, 0.3); }
.msg-row.other .msg-file:hover { background: rgba(0, 0, 0, 0.1); }

/* 3. Action Toolbar (Edit/Delete/Download) */
.msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    opacity: 0; /* Hidden by default on desktop */
    transition: opacity 0.2s ease;
}

.msg-row.mine .msg-actions { border-bottom-color: rgba(255,255,255,0.3); }

/* Show on hover */
.msg-bubble:hover .msg-actions { opacity: 1; }

/* 4. Action Buttons (The small icons) */
.win11-icon-btn {
    background: transparent;
    border: none;
    padding: 0;
    width: 28px;        /* Fixed square size */
    height: 28px;       
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
    transition: background 0.2s;
}

.win11-icon-btn svg {
    width: 16px;        /* Fixed icon size */
    height: 16px;
    pointer-events: none;
}

.win11-icon-btn:hover { background: rgba(0,0,0,0.1); }
.msg-row.mine .win11-icon-btn:hover { background: rgba(255,255,255,0.2); }

/* INPUT AREA */
.input-area { padding: 10px 16px; background: white; border-top: 1px solid var(--border); }
.input-bar {
    background: #f1f5f9;
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}
.input-field { flex: 1; background: transparent; border: none; font-size: 15px; }

/* TABLES (Admin) */
.table-responsive { width: 100%; overflow-x: auto; }
.file-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.file-table th, .file-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.file-table th { background: #f8f9fa; font-size: 13px; color: var(--text-muted); text-transform: uppercase; }

/* PREVIEW BOX */
.preview-area {
    display: none; position: absolute; bottom: 100%; left: 16px;
    background: white; padding: 10px; border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1); margin-bottom: 10px;
}
.preview-area.active { display: flex; align-items: center; gap: 10px; }
.preview-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }

/* --- RESPONSIVE BREAKPOINTS --- */
@media (max-width: 768px) {
    /* Login Page */
    .form-card { width: 90%; padding: 25px; }
    
    /* Sidebar Layout */
    .mobile-menu-btn { display: block; } /* Show hamburger */
    
    .sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 80%; /* Wider on mobile */
        max-width: 300px;
        transform: translateX(-100%); /* Hide by default */
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    
    .sidebar.open { transform: translateX(0); } /* Slide in */
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: absolute; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5); z-index: 45;
        display: none;
    }
    .sidebar.open + .sidebar-overlay { display: block; }
    
    /* CHAT RESPONSIVENESS FIXES */
    
    /* 1. Always show action buttons on mobile (no hover state) */
    .msg-actions {
        opacity: 1;
        border-bottom-color: rgba(0,0,0,0.1);
    }
    .msg-row.mine .msg-actions { border-bottom-color: rgba(255,255,255,0.2); }

    /* 2. Cap image height more aggressively on small screens */
    .msg-img {
        max-height: 200px; 
    }

    /* 3. Make buttons slightly larger touch targets */
    .win11-icon-btn {
        width: 32px;
        height: 32px;
    }
}