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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

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

.screen.active {
    display: flex;
}

.screen.overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    color: #764ba2;
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.logo p {
    color: #666;
    font-size: 0.9em;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: #f0f0f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

.tab.active {
    background: #764ba2;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Forms */
input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #764ba2;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-small {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: #764ba2;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

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

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.3s;
}

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

/* Messages */
.message {
    padding: 10px;
    margin-top: 10px;
    border-radius: 8px;
    text-align: left;
    display: none;
    white-space: pre-line;
    font-size: 0.9em;
    line-height: 1.5;
}

.message.error {
    background: #fee;
    color: #c33;
    display: block;
    border-left: 4px solid #c33;
}

.message.success {
    background: #efe;
    color: #3c3;
    display: block;
    border-left: 4px solid #3c3;
}

/* Main App */
.app-container {
    display: flex;
    height: 100vh;
    background: #f0f2f5;
    max-width: 1600px;
    margin: 0 auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: white;
    border-right: 1px solid #e9edef;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px 20px;
    background: #764ba2;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info .icon-btn {
    color: white;
    font-size: 1.3em;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.user-info .icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Subscription Status */
.subscription-status {
    padding: 15px 20px;
    background: white;
    border-bottom: 1px solid #e9edef;
}

.sub-tier {
    font-weight: 600;
    color: #764ba2;
    margin-bottom: 5px;
}

.sub-storage {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
}

/* Search Box */
.search-box {
    padding: 8px 12px;
    background: #f6f6f6;
    border-bottom: 1px solid #e9edef;
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 45px;
    background: white;
    border: 1px solid #e9edef;
    border-radius: 8px;
    font-size: 0.95em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    margin-bottom: 0;
}

.search-box input:focus {
    border-color: #764ba2;
    outline: none;
}

/* Contacts */
.contacts-section {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f6f6f6;
    border-bottom: 1px solid #e9edef;
}

.section-header h3 {
    color: #333;
    font-size: 0.95em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contacts-list {
    display: flex;
    flex-direction: column;
}

.contact-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.contact-item:hover {
    background: #f5f6f6;
}

.contact-item.active {
    background: #ede7f6;
    border-left: 4px solid #764ba2;
}

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.2em;
    flex-shrink: 0;
    position: relative;
}

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

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.contact-name {
    font-weight: 600;
    font-size: 1em;
    color: #111;
}

.contact-time {
    font-size: 0.75em;
    color: #667eea;
}

.contact-last-message {
    font-size: 0.875em;
    color: #667781;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-item.active .contact-time,
.contact-item.active .contact-last-message {
    color: #764ba2;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(118, 75, 162, 0.03) 10px, rgba(118, 75, 162, 0.03) 20px);
}

.no-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #667781;
    background: #f8f9fa;
}

.no-chat-icon {
    font-size: 5em;
    margin-bottom: 20px;
    color: #764ba2;
    opacity: 0.3;
}

.no-chat-text {
    font-size: 1.3em;
    font-weight: 300;
    color: #41525d;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 12px 20px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
}

.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.contact-info h3 {
    margin: 0;
    font-size: 1.05em;
    color: #111;
}

.status {
    font-size: 0.8em;
    color: #667781;
    margin-top: 2px;
}

.status.online {
    color: #00a884;
}

.status.online::before {
    content: "●";
    margin-right: 5px;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-actions .icon-btn {
    color: #667781;
    font-size: 1.3em;
}

.chat-actions .icon-btn:hover {
    color: #764ba2;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 8%;
    background: #efeae2;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(118, 75, 162, 0.03) 10px, rgba(118, 75, 162, 0.03) 20px);
}

.message-item {
    display: flex;
    margin-bottom: 8px;
    animation: slideIn 0.2s ease;
}

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

.message-item.sent {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 65%;
    padding: 6px 10px 8px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message-item.sent .message-bubble {
    background: #d9fdd3;
    color: #111;
}

.message-item.sent .message-bubble::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 12px 12px;
    border-color: transparent transparent #d9fdd3 transparent;
}

.message-item.received .message-bubble::after {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 12px 12px 0;
    border-color: transparent white transparent transparent;
}

.message-text {
    word-wrap: break-word;
    margin-bottom: 2px;
    font-size: 0.95em;
    line-height: 1.4;
    color: #111;
}

.message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.message-time {
    font-size: 0.7em;
    color: #667781;
}

.message-status {
    font-size: 0.8em;
    color: #667781;
}

.message-item.sent .message-status {
    color: #53bdeb;
}

.message-item.sent .message-status.delivered {
    color: #53bdeb;
}

.message-item.sent .message-status.read {
    color: #53bdeb;
}

/* Message Input */
.message-input-container {
    padding: 10px 20px;
    background: #f0f2f5;
    border-top: 1px solid #e9edef;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-actions .icon-btn {
    color: #667781;
    font-size: 1.5em;
    padding: 8px;
}

.input-actions .icon-btn:hover {
    color: #764ba2;
}

#message-input {
    flex: 1;
    margin-bottom: 0;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid #e9edef;
    background: white;
    font-size: 0.95em;
    resize: none;
    max-height: 120px;
    min-height: 44px;
}

#message-input:focus {
    border-color: #764ba2;
}

.send-btn {
    background: #764ba2;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3em;
    transition: all 0.3s;
}

.send-btn:hover {
    background: #667eea;
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Call Screen */
.call-container {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    padding: 40px;
}

.call-info {
    text-align: center;
    color: white;
}

.call-info h2 {
    font-size: 2em;
    margin-bottom: 10px;
}

.video-container {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#remote-video {
    width: 100%;
    max-width: 1200px;
    border-radius: 20px;
}

#local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    border-radius: 10px;
    border: 3px solid white;
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}

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

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.control-btn.end-call {
    background: #f44336;
}

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

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.small {
    max-width: 400px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

/* Settings */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    margin-bottom: 15px;
    color: #764ba2;
}

.storage-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.storage-progress {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s;
}

.info-text {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

/* Plans */
.plans-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.plan-card {
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.plan-card:hover {
    border-color: #764ba2;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.plan-card.selected {
    border-color: #764ba2;
    background: #f0f4ff;
}

.plan-name {
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 10px;
    color: #764ba2;
}

.plan-price {
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 10px;
}

.plan-storage {
    color: #666;
    margin-bottom: 15px;
}

.plan-features {
    list-style: none;
    text-align: left;
    font-size: 0.9em;
}

.plan-features li {
    padding: 5px 0;
    color: #666;
}

.plan-features li:before {
    content: "✓ ";
    color: #4caf50;
    font-weight: bold;
}

/* Payment */
.payment-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.crypto-selector,
.duration-selector {
    margin-bottom: 15px;
}

.crypto-selector label,
.duration-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.payment-address {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 15px 0;
}

.payment-address code {
    flex: 1;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: 0.9em;
    word-break: break-all;
}

#payment-qr {
    text-align: center;
    margin: 20px 0;
}

.payment-status {
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
}

.payment-status.pending {
    background: #fff3cd;
    color: #856404;
}

.payment-status.confirmed {
    background: #d4edda;
    color: #155724;
}

.payment-status.failed {
    background: #f8d7da;
    color: #721c24;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667781;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Unread Badge */
.unread-badge {
    background: #764ba2;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75em;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Online Indicator */
.online-indicator {
    width: 12px;
    height: 12px;
    background: #00a884;
    border-radius: 50%;
    border: 2px solid white;
    position: absolute;
    bottom: 0;
    right: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -380px;
        transition: left 0.3s;
        z-index: 100;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .plans-container {
        grid-template-columns: 1fr;
    }
    
    .message-bubble {
        max-width: 80%;
    }
    
    #local-video {
        width: 120px;
        bottom: 10px;
        right: 10px;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
