/* ========================================
SECURE ENCRYPTION TOOL - MOBILE OPTIMIZED
======================================== */

/* ===== VARIABLES ===== */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --dark: #1a202c;
    --light: #f7fafc;
    --gray-100: #f7fafc;
    --gray-200: #edf2f7;
    --gray-300: #e2e8f0;
    --gray-400: #cbd5e0;
    --gray-500: #a0aec0;
    --gray-600: #718096;
    --gray-700: #4a5568;
    --gray-800: #2d3748;
    --gray-900: #1a202c;
    
    --border-radius-sm: 12px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-xl: 32px;
    
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    --spacing-xxl: 24px;
}

/* Dark theme variables */
body.dark-theme {
    --primary: #5a67d8;
    --primary-dark: #4c51bf;
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --border-color: #4a5568;
    --card-bg: #2d3748;
}

/* Light theme (default) */
body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
}

/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    transition: background 0.3s ease, color 0.3s ease;
    font-size: 14px;
    line-height: 1.5;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== LOGIN PAGE ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 16px;
}

.login-box {
    background: var(--card-bg);
    border-radius: var(--border-radius-xl);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    padding: 32px 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header h1 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.security-features {
    background: rgba(102, 126, 234, 0.1);
    padding: 20px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 24px;
    text-align: left;
    border-left: 4px solid var(--primary);
}

.security-features h3 {
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 16px;
    font-weight: 600;
}

.security-features ul {
    list-style: none;
    padding-left: 0;
}

.security-features li {
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== MAIN CONTAINER ===== */
.container {
    background: var(--card-bg);
    border-radius: var(--border-radius-xl);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    padding: 20px 16px;
    max-width: 450px;
    width: 100%;
    transition: all 0.3s ease;
    display: none;
    position: relative;
    margin: 10px;
}

/* ===== HEADER ===== */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.theme-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    min-width: 70px;
    color: var(--text-primary);
}

.theme-btn:active {
    transform: scale(0.95);
    background: var(--gray-300);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.avatar:active {
    transform: scale(0.95);
}

.username {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: var(--danger);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-logout:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* ===== TITLE ===== */
.mobile-title {
    font-size: 24px;
    margin-bottom: 4px;
    text-align: center;
    color: var(--text-primary);
}

.mobile-subtitle {
    font-size: 13px;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ===== QUICK ACTIONS ===== */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-btn {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 40px;
}

.tab {
    background: none;
    border: none;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 40px;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== INSTRUCTIONS ===== */
.instructions {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary);
}

.instructions h4 {
    font-size: 15px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.instructions ul {
    padding-left: 20px;
    line-height: 1.6;
    font-size: 13px;
    color: var(--text-secondary);
}

.instructions li {
    margin-bottom: 4px;
}

.warning-text {
    color: var(--danger);
    font-weight: 600;
    margin-top: 8px;
}

/* ===== INPUT GROUPS ===== */
.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    font-size: 15px;
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-appearance: none;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.char-counter {
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== PASSWORD INPUT ===== */
.password-input {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    z-index: 1;
}

.toggle-password:active {
    opacity: 0.7;
}

/* Password strength indicator */
.password-strength {
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s, background 0.3s;
}

.strength-bar.weak {
    width: 33.33%;
    background: var(--danger);
}

.strength-bar.medium {
    width: 66.66%;
    background: var(--warning);
}

.strength-bar.strong {
    width: 100%;
    background: var(--secondary);
}

/* ===== BUTTONS ===== */
.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 40px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
    display: inline-block;
    width: 100%;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-secondary {
    background: var(--secondary);
}

.btn-success {
    background: var(--secondary);
}

.mobile-btn {
    padding: 14px 16px;
    font-size: 15px;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.copy-btn, .share-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn {
    background: var(--primary);
    color: white;
}

.share-btn {
    background: var(--secondary);
    color: white;
}

.copy-btn:active, .share-btn:active {
    transform: scale(0.98);
}

/* ===== RESULTS ===== */
.result {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    margin: 16px 0;
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.encrypted-text {
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    margin: 10px 0;
    word-break: break-all;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* ===== STATUS MESSAGES ===== */
.status {
    padding: 14px;
    border-radius: var(--border-radius-md);
    margin: 12px 0;
    font-weight: 500;
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

.status.success {
    background: rgba(72, 187, 120, 0.1);
    color: var(--secondary);
    border-left: 4px solid var(--secondary);
}

.status.error {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

.status.warning {
    background: rgba(237, 137, 54, 0.1);
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

/* ===== FILE INPUT ===== */
.file-input {
    margin-bottom: 16px;
}

.file-label {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 20px;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    border: 2px dashed var(--border-color);
    transition: all 0.2s;
}

.file-label:active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.file-hint {
    font-size: 11px;
    font-weight: normal;
    color: var(--text-secondary);
    margin-top: 6px;
}

.file-label:active .file-hint {
    color: rgba(255, 255, 255, 0.8);
}

input[type="file"] {
    display: none;
}

.file-info {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    border-left: 4px solid var(--primary);
}

.file-details {
    background: var(--bg-primary);
    border-radius: var(--border-radius-md);
    padding: 12px;
    margin: 12px 0;
}

.file-details p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-primary);
}

.file-icon {
    font-size: 16px;
    min-width: 24px;
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
    background: var(--bg-secondary);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
    margin: 16px 0;
    display: none;
    position: relative;
}

.progress {
    background: var(--primary);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 20px;
}

.progress-text {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== FILE PREVIEW ===== */
.file-preview {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 12px;
    margin: 12px 0;
    border: 1.5px solid var(--border-color);
}

.file-preview h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.preview-container {
    max-height: 200px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.preview-image {
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
}

.preview-pdf {
    width: 100%;
    height: 200px;
    border: none;
}

.preview-text {
    max-height: 150px;
    overflow: auto;
    background: var(--bg-primary);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    font-family: monospace;
    font-size: 11px;
    width: 100%;
    color: var(--text-primary);
}

.preview-audio,
.preview-video {
    width: 100%;
    max-height: 150px;
}

.preview-icon {
    font-size: 48px;
    text-align: center;
    margin: 10px 0;
}

/* ===== HISTORY TAB ===== */
.history-list {
    margin: 16px 0;
    max-height: 300px;
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 13px;
}

.history-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    padding: 12px;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

.history-item .history-action {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.history-item .history-details {
    font-size: 11px;
    color: var(--text-secondary);
}

.clear-history {
    background: var(--danger);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    margin-top: 12px;
}

.clear-history:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ===== FLOATING ACTION BUTTON ===== */
.fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.2s;
    z-index: 100;
}

.fab:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* ===== MOBILE USER MENU ===== */
.user-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(5px);
}

.user-menu-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    border-radius: 30px 30px 0 0;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-menu-header img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.user-menu-info {
    display: flex;
    flex-direction: column;
}

.user-menu-info span:first-child {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-email {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.user-menu-item {
    padding: 16px;
    font-size: 15px;
    cursor: pointer;
    border-radius: var(--border-radius-md);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-primary);
}

.user-menu-item:active {
    background: var(--bg-secondary);
}

.user-menu-item.logout {
    color: var(--danger);
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    padding-top: 16px;
}

.user-menu-item.close {
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
}

.menu-icon {
    font-size: 20px;
    min-width: 24px;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 20px;
    right: 20px;
    background: var(--gray-800);
    color: white;
    padding: 16px;
    border-radius: 30px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    animation: slideUp 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    padding: 16px;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--border-radius-xl);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeInUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.modal-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
}

.modal-body {
    padding: 20px;
}

.faq-item {
    margin-bottom: 20px;
}

.faq-item h4 {
    font-size: 15px;
    color: var(--primary);
    margin-bottom: 8px;
}

.faq-item p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.mobile-hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 380px) {
    .username {
        max-width: 70px;
    }
    
    .tab {
        font-size: 12px;
        padding: 8px 0;
    }
    
    .mobile-title {
        font-size: 22px;
    }
    
    .btn {
        font-size: 14px;
    }
}

@media (min-width: 450px) {
    .container {
        margin: 20px auto;
    }
}

/* ===== DARK THEME SPECIFIC ===== */
body.dark-theme .login-box {
    background: #2d3748;
}

body.dark-theme .security-features {
    background: rgba(102, 126, 234, 0.2);
}

body.dark-theme input,
body.dark-theme textarea {
    background: #1a202c;
    border-color: #4a5568;
    color: #f7fafc;
}

body.dark-theme .file-label {
    background: #2d3748;
    border-color: #4a5568;
}

body.dark-theme .result {
    background: #1a202c;
}

body.dark-theme .encrypted-text {
    background: #2d3748;
    border-color: #4a5568;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 2s infinite;
}