:root {
    --primary-color: #128C7E;
    --primary-dark: #075E54;
    --secondary-color: #25D366;
    --background: #f0f2f5;
    --sidebar-bg: #ffffff;
    --chat-bg: #e5ddd5;
    --message-sent: #dcf8c6;
    --message-received: #ffffff;
    --text-primary: #000000;
    --text-secondary: #667781;
    --border-color: #e9edef;
    --error-color: #dc3545;
    --success-color: #28a745;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    width: 100vw;
    height: 100vh;
}

.screen.active {
    display: flex;
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

.login-box {
    background: white;
    padding: 3rem 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    padding: 0.625rem 1.25rem;
    background: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #556269;
}

.signup-text {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.error-message {
    color: var(--error-color);
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* Admin Panel */
.admin-container {
    width: 100%;
    height: 100%;
    background: var(--background);
    overflow-y: auto;
}

.admin-header {
    background: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header h1 {
    color: var(--primary-color);
    font-size: 1.75rem;
}

.admin-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.requests-list, .users-list, .groups-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.request-card, .user-card, .group-card {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.3s;
}

.request-card:hover, .user-card:hover, .group-card:hover {
    box-shadow: var(--shadow);
}

.card-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.card-details h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.card-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-approve {
    padding: 0.5rem 1rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: opacity 0.3s;
}

.btn-approve:hover {
    opacity: 0.9;
}

.btn-reject, .btn-block {
    padding: 0.5rem 1rem;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: opacity 0.3s;
}

.btn-reject:hover, .btn-block:hover {
    opacity: 0.9;
}

.access-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.floating-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

/* Chat Screen */
.chat-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.search-box {
    padding: 0.75rem;
    background: var(--background);
}

.search-box input {
    width: 100%;
    padding: 0.625rem;
    border: none;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.chat-item:hover {
    background: var(--background);
}

.chat-item.active {
    background: var(--background);
}

.chat-item .user-avatar {
    width: 50px;
    height: 50px;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.chat-item-name {
    font-weight: 600;
    font-size: 1rem;
}

.chat-item-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-item-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--secondary-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
}

.no-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
}

.no-chat h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: var(--sidebar-bg);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header-info .user-avatar {
    width: 45px;
    height: 45px;
}

.chat-header-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.125rem;
}

.user-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 65%;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    word-wrap: break-word;
    position: relative;
}

.message.sent {
    background: var(--message-sent);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message.received {
    background: var(--message-received);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
}

.message-input-container {
    padding: 1rem;
    background: var(--sidebar-bg);
    display: flex;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.message-input-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 0.95rem;
}

.message-input-container input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-send:hover {
    background: var(--primary-dark);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: var(--primary-dark);
    font-size: 1.25rem;
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.users-select h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.user-checkbox {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.user-checkbox:hover {
    background: var(--background);
}

.user-checkbox input {
    margin-right: 0.75rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Call Modal */
.call-modal {
    max-width: 800px;
}

.call-header {
    padding: 1.5rem;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.call-header .close-modal {
    color: white;
}

.call-body {
    padding: 0;
    position: relative;
    background: #000;
    min-height: 500px;
}

#localVideo, #remoteVideo {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
}

#localVideo {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    max-height: 150px;
    border: 2px solid white;
    border-radius: 8px;
    z-index: 10;
}

.call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 10;
}

.call-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transition: background 0.3s;
}

.call-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.call-btn.end-call {
    background: var(--error-color);
}

.call-btn.end-call:hover {
    background: #c82333;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-dark);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        height: 100%;
    }
    
    .sidebar.hidden {
        display: none;
    }
    
    .chat-area {
        width: 100%;
    }
    
    .message {
        max-width: 80%;
    }
}
