/* ========================================
   ENCODEX - ENHANCED GLASSMORPHISM UI
   ======================================== */

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

:root {
    /* Dark Mode Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-primary: #6366f1;
    --accent-hover: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Glassmorphism Effects */
    --blur: 20px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Variables */
body.light-mode {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: var(--transition);
}

/* Animated Background Gradient */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: 
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
    animation: gradientShift 15s ease infinite;
    transition: var(--transition);
}

body.light-mode .background-gradient {
    background: 
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 70%);
}

@keyframes gradientShift {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 12px 48px rgba(99, 102, 241, 0.3);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease;
}

.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.logo-icon {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 4px 20px rgba(99, 102, 241, 0.4));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
}

/* Templates Section */
.templates-section {
    margin-bottom: 2rem;
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.templates-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.template-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.template-btn {
    padding: 0.625rem 1.25rem;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.template-btn:hover, .template-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 500px), 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Glassmorphism Box */
.glass-box {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    animation: fadeInUp 0.8s ease;
    position: relative;
    overflow: hidden;
}

.glass-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: left 0.6s ease;
}

.glass-box:hover::before {
    left: 100%;
}

.glass-box:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 12px 48px rgba(99, 102, 241, 0.2);
    transform: translateY(-4px);
}

.box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.box-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.1);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.char-counter {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

textarea,
input[type="password"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.875rem;
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
    resize: vertical;
}

body.light-mode textarea,
body.light-mode input[type="password"] {
    background: rgba(0, 0, 0, 0.03);
}

textarea {
    min-height: 120px;
}

textarea:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea::placeholder,
input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

textarea[readonly] {
    background: rgba(255, 255, 255, 0.02);
    cursor: default;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

body.light-mode textarea[readonly] {
    background: rgba(0, 0, 0, 0.02);
}

/* Password Input Group */
.password-input-group {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.password-input-group input {
    flex: 1;
}

.toggle-password,
.generate-password {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 45px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password {
    right: 45px;
}

.toggle-password:hover,
.generate-password:hover {
    transform: scale(1.2);
}

/* Password Strength Meter */
.strength-meter {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

body.light-mode .strength-meter {
    background: rgba(0, 0, 0, 0.1);
}

.strength-bar {
    height: 100%;
    width: 0%;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.strength-bar.weak {
    width: 33%;
    background: var(--error);
}

.strength-bar.medium {
    width: 66%;
    background: var(--warning);
}

.strength-bar.strong {
    width: 100%;
    background: var(--success);
}

.strength-text {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.strength-text.weak {
    color: var(--error);
}

.strength-text.medium {
    color: var(--warning);
}

.strength-text.strong {
    color: var(--success);
}

/* Checkbox Group */
.checkbox-group {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

body.light-mode .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
}

.btn-small {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    width: auto;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-text {
    position: relative;
    z-index: 1;
}

/* Output Actions */
.output-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

/* Output Group */
.output-group {
    animation: slideIn 0.4s ease;
}

/* QR Container */
.qr-container {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    text-align: center;
    animation: slideIn 0.4s ease;
}

body.light-mode .qr-container {
    background: rgba(0, 0, 0, 0.02);
}

.qr-container h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

#qr-encrypt-code {
    display: inline-block;
    padding: 1rem;
    background: white;
    border-radius: 12px;
}

.qr-hint {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Message Age Warning */
.message-age {
    margin-top: 1rem;
    padding: 0.875rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--warning);
}

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 1rem;
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
    animation: shake 0.5s ease;
}

/* History Section */
.history-section {
    margin-bottom: 3rem;
    animation: fadeInUp 1s ease;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

body.light-mode .history-item {
    background: rgba(0, 0, 0, 0.02);
}

.history-item:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

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

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

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

.history-note {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Footer Info Box */
footer {
    animation: fadeInUp 1s ease;
}

.info-box {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.info-box h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.info-box ul {
    list-style: none;
}

.info-box li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.info-box li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent-primary);
    font-weight: bold;
}

.info-box strong {
    color: var(--text-primary);
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.feature {
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.feature:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideInScale 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--error);
    transform: rotate(90deg);
}

.generated-passphrase {
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border: 2px dashed var(--accent-primary);
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    word-break: break-all;
}

.generator-options {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

@keyframes slideInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .logo-icon {
        width: 60px;
        height: 60px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .glass-box {
        padding: 1.5rem;
    }
    
    .template-buttons {
        flex-direction: column;
    }
    
    .output-actions {
        flex-direction: column;
    }
    
    .output-actions .btn-small {
        width: 100%;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-actions {
        flex-direction: column;
    }
}

/* Utility: Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection color */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: white;
}

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}