/* ============================================================
   PHP WebRTC Video Call - Google Meet Style v5
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Google Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: #202124;
    min-height: 100vh;
    color: #e8eaed;
    overflow: hidden;
}

#app {
    width: 100vw;
    height: 100vh;
}

/* ============================================================
   AUTH & DASHBOARD
   ============================================================ */

#auth-section, #dashboard-section {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.auth-card {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #8ab4f8, #a365f6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.auth-icon .material-icons-round {
    font-size: 32px;
    color: white;
}

.auth-card h2 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #e8eaed;
}

.auth-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    margin-bottom: 24px;
}

input {
    width: 100%;
    padding: 14px 16px;
    margin: 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #e8eaed;
    font-size: 15px;
    transition: all 0.2s ease;
    outline: none;
}

input:focus {
    border-color: #8ab4f8;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.2);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

button {
    background: #8ab4f8;
    color: #202124;
}

button:hover {
    background: #aecbfa;
    transform: translateY(-1px);
}

button.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ============================================================
   ROOM LIST
   ============================================================ */

#room-list {
    margin: 20px 0;
    text-align: left;
}

#room-list h3 {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

ul {
    list-style: none;
    padding: 0;
}

li {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px;
    transition: background 0.2s;
}

li:hover {
    background: rgba(255, 255, 255, 0.04);
}

li span {
    font-size: 14px;
}

li span small {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
}

li button {
    padding: 6px 16px;
    font-size: 12px;
}

.room-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.room-controls input {
    flex: 1;
    margin: 0;
}

.room-controls button {
    flex: none;
    padding: 12px 20px;
    white-space: nowrap;
}

/* ============================================================
   VIDEO CALL LAYOUT (Google Meet Style)
   ============================================================ */

#video-section {
    height: 100vh;
    display: flex;
    width: 100vw;
    overflow: hidden;
}

.call-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-width: 0;
}

/* Header Bar */
.call-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(32, 33, 36, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.call-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 500;
}

.call-title .material-icons-round {
    font-size: 20px;
    color: #8ab4f8;
}

.call-info, .call-members {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

.call-info .material-icons-round,
.call-members .material-icons-round {
    font-size: 16px;
}

/* Video Area */
.video-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
}

/* Video Grid */
.video-grid {
    display: grid;
    gap: 8px;
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 160px);
}

.grid-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    max-width: 700px;
    margin: 0 auto;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.grid-6 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.grid-9 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

.grid-many {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-template-rows: repeat(auto-fill, minmax(150px, 1fr));
}

/* Audio-only tile */
.audio-only-tile {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3c4043, #2d2e30);
    border-radius: 12px;
}

.avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8ab4f8, #a365f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: white;
    margin-bottom: 16px;
}

.audio-label {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

/* Video Tiles */
.video-tile {
    position: relative;
    background: #3c4043;
    border-radius: 12px;
    overflow: hidden;
    min-height: 0;
}

.video-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tile-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
}

.tile-name {
    font-weight: 500;
}

.mic-icon {
    font-size: 14px !important;
    color: #e8eaed;
}

/* Bottom Controls */
.call-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(32, 33, 36, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.ctrl-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    padding: 0;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.ctrl-btn .material-icons-round {
    font-size: 22px;
    color: #e8eaed;
}

.ctrl-btn.muted {
    background: #ea4335;
}

.ctrl-btn.muted .material-icons-round {
    color: white;
}

.ctrl-btn.leave {
    background: #ea4335;
    margin-left: 8px;
}

.ctrl-btn.leave:hover {
    background: #d93025;
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ea4335;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ============================================================
   SIDEBAR (Chat + Participants)
   ============================================================ */

.sidebar {
    width: 340px;
    height: 100%;
    background: #292b2e;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

/* Close button - top right corner */
.close-sidebar {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.2s;
    z-index: 10;
}

.close-sidebar:hover {
    background: rgba(255, 255, 255, 0.1);
}

.close-sidebar .material-icons-round {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.6);
}

/* Tab Header */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    padding-right: 40px; /* Space for close button */
}

.tab-btn {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.tab-btn.active {
    color: #8ab4f8;
    border-bottom-color: #8ab4f8;
}

.tab-btn .material-icons-round {
    font-size: 18px;
}

/* Tab Panels */
.tab-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: rgba(255, 255, 255, 0.3);
    gap: 8px;
}

.chat-welcome .material-icons-round {
    font-size: 40px;
}

.chat-welcome p {
    font-size: 13px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chat Bubble */
.chat-message {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 85%;
    animation: fadeIn 0.15s ease;
}

.chat-me {
    align-self: flex-end;
    background: rgba(138, 180, 248, 0.12);
    border: 1px solid rgba(138, 180, 248, 0.15);
}

.chat-other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-sender {
    font-size: 11px;
    font-weight: 600;
    color: #8ab4f8;
    margin-bottom: 3px;
}

.chat-other .chat-sender {
    color: #a365f6;
}

.chat-text {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 3px;
    text-align: right;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    margin: 0;
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e8eaed;
}

.chat-input-area input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #8ab4f8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #aecbfa;
}

.send-btn .material-icons-round {
    font-size: 16px;
    color: #202124;
}

/* Participants Panel */
.participants-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.participant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8ab4f8, #a365f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.participant-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.participant-name {
    font-size: 13px;
    font-weight: 500;
}

.participant-status {
    font-size: 11px;
    color: #34a853;
}

.participant-badge {
    font-size: 16px;
    color: #8ab4f8;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    /* Sidebar tetap di kanan, lebih sempit di HP */
    .sidebar {
        width: 280px !important;
    }

    /* Call controls - compact */
    .call-controls {
        gap: 6px;
        padding: 8px 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .ctrl-btn {
        width: 40px;
        height: 40px;
    }

    .ctrl-btn .material-icons-round {
        font-size: 20px;
    }

    /* Header */
    .call-header {
        padding: 8px 12px;
    }

    .call-title {
        font-size: 13px;
    }

    .call-info, .call-members {
        font-size: 11px;
    }

    /* Video grid */
    .grid-2 {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .grid-4, .grid-6, .grid-9 {
        grid-template-columns: 1fr 1fr;
    }

    .video-area {
        padding: 6px;
    }

    .video-grid {
        max-height: calc(100vh - 120px);
        gap: 4px;
    }

    .tile-info {
        font-size: 10px;
        padding: 3px 6px;
        bottom: 4px;
        left: 4px;
    }

    .tile-info .material-icons-round {
        font-size: 12px !important;
    }

    /* Audio only tile smaller */
    .avatar-large {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }

    .audio-label {
        font-size: 13px;
    }
}

/* Tablet size */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 300px;
    }
}

/* Small phone */
@media (max-width: 420px) {
    .ctrl-btn {
        width: 36px;
        height: 36px;
    }

    .ctrl-btn .material-icons-round {
        font-size: 18px;
    }

    .call-controls {
        gap: 4px;
        padding: 6px 8px;
    }

    .chat-message {
        max-width: 90%;
    }

    /* Sidebar tetap di kanan */
    .sidebar {
        width: 260px !important;
    }

    .sidebar-tabs {
        padding-right: 40px;
    }

    .chat-messages {
        padding: 8px;
        gap: 6px;
    }

    .chat-message {
        padding: 6px 10px;
        border-radius: 10px;
    }

    .chat-text {
        font-size: 12px;
    }

    .chat-input-area {
        padding: 8px 10px;
    }

    .chat-input-area input {
        font-size: 12px;
        padding: 8px 12px;
    }

    .send-btn {
        width: 30px;
        height: 30px;
    }

    .send-btn .material-icons-round {
        font-size: 14px;
    }

    .close-sidebar {
        top: 6px;
        right: 6px;
        width: 32px;
        height: 32px;
    }

    .close-sidebar .material-icons-round {
        font-size: 18px;
    }
}
