/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
    height: 100vh;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

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

.loading-container {
    text-align: center;
    color: white;
}

.logo {
    margin-bottom: 2rem;
}

.logo i {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.logo p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* QR Authentication Screen */
#qr-auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.auth-container {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.auth-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: #666;
    font-size: 0.95rem;
}

.qr-section {
    text-align: center;
    margin-bottom: 2rem;
}

#qr-code-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    display: inline-block;
}

#qr-canvas {
    border-radius: 10px;
}

.qr-info {
    font-size: 0.85rem;
    color: #666;
}

.qr-info p {
    margin-bottom: 0.25rem;
}

.auth-form {
    margin-bottom: 2rem;
}

.missing-words h3,
.pin-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.word-inputs {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.word-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.word-input-group label {
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}

.word-input-group input {
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.word-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.pin-inputs {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.pin-digit {
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    transition: border-color 0.2s;
}

.pin-digit:focus {
    outline: none;
    border-color: #667eea;
}

.auth-button {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.auth-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.security-info {
    text-align: center;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #f0f9ff;
    color: #0369a1;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Main Application */
#main-app-screen {
    background: #f8f9fa;
}

.app-header {
    background: white;
    border-bottom: 1px solid #e1e5e9;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.logo-small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #667eea;
}

.logo-small i {
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.header-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    transition: background-color 0.2s;
}

.header-btn:hover {
    background: #f3f4f6;
}

.app-content {
    display: flex;
    height: calc(100vh - 70px);
}

.sidebar {
    width: 350px;
    background: white;
    border-right: 1px solid #e1e5e9;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #e1e5e9;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: #666;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.tab-btn.active {
    color: #667eea;
    background: #f8f9ff;
}

.tab-btn i {
    font-size: 1.2rem;
}

.tab-content {
    flex: 1;
    overflow: hidden;
}

.tab-panel {
    height: 100%;
    display: none;
    flex-direction: column;
}

.tab-panel.active {
    display: flex;
}

.tab-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tab-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.add-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.add-btn:hover {
    transform: scale(1.1);
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
    text-align: center;
    padding: 2rem;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.empty-state small {
    opacity: 0.7;
}

.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-screen {
    text-align: center;
    color: #666;
}

.welcome-content i {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.welcome-content h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.welcome-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 300px;
    margin: 0 auto;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.feature i {
    color: #667eea;
    font-size: 1.2rem;
}

/* Settings Content */
.settings-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 2rem;
}

.setting-group h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.setting-value {
    font-weight: 500;
    color: #667eea;
}

.contact-code-display {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1rem;
}

#my-contact-words {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    word-break: break-all;
}

.share-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.share-btn:hover {
    background: #5a67d8;
}

/* Identity Tab Styles */
.identity-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.identity-section {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.identity-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.qr-display {
    text-align: center;
}

.qr-actions, .words-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.action-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background: #5a67d8;
}

.action-btn.primary {
    background: #10b981;
}

.action-btn.primary:hover {
    background: #059669;
}

.danger-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.danger-btn:hover {
    background: #dc2626;
}

.words-display {
    background: white;
    border-radius: 8px;
    padding: 1rem;
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.word-item {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.5rem;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    position: relative;
}

.word-number {
    position: absolute;
    top: -8px;
    left: 4px;
    background: #667eea;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.security-info-grid {
    display: grid;
    gap: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.info-label {
    font-weight: 500;
    color: #374151;
}

.info-value {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 600;
}

.profile-settings {
    background: white;
    border-radius: 8px;
    padding: 1rem;
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.setting-row label {
    font-weight: 500;
    color: #374151;
}

.setting-row input {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
}

.setting-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Enhanced Settings Styles */
.setting-select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #667eea;
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Voice Call Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.voice-call-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.call-header {
    margin-bottom: 2rem;
}

.call-status {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 3rem;
}

.call-contact-info h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

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

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

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

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

.call-info {
    display: flex;
    justify-content: space-around;
    font-size: 0.9rem;
    opacity: 0.8;
}

.call-quality, .call-encryption {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Modal Styles */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background: #f3f4f6;
}

.add-contact-options {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.option-btn i {
    font-size: 1.5rem;
    color: #667eea;
}

.contact-input-section {
    margin-top: 1rem;
}

.contact-input-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.contact-input-section textarea,
.contact-input-section input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.contact-input-section textarea:focus,
.contact-input-section input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .auth-container {
        margin: 1rem;
        padding: 2rem;
    }

    .pin-inputs {
        gap: 0.5rem;
    }

    .pin-digit {
        width: 45px;
        height: 45px;
    }

    .words-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
    }

    .call-controls {
        gap: 0.5rem;
    }

    .call-control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}
