* { margin: 0; padding: 0; box-sizing: border-box; }

/* Back Button */
.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    background: rgba(18, 18, 26, 0.9);
    border: 1px solid #2a2a3a;
    color: #00f5d4;
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    z-index: 100;
    transition: all 0.3s;
}

.back-btn:hover {
    background: rgba(0, 245, 212, 0.1);
    border-color: #00f5d4;
    box-shadow: 0 0 20px rgba(0, 245, 212, 0.3);
}

:root {
    --bg-dark: #0a0a0f;
    --bg-panel: #12121a;
    --accent-cyan: #00f5d4;
    --accent-magenta: #f72585;
    --accent-yellow: #fee440;
    --text-primary: #e0e0e0;
    --text-dim: #5a5a6e;
    --border-color: #2a2a3a;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scanline effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.1) 2px,
        rgba(0, 0, 0, 0.1) 4px
    );
    pointer-events: none;
    z-index: 1000;
}

/* Grid background */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 245, 212, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 245, 212, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
}

/* Floating particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-cyan);
    border-radius: 50%;
    opacity: 0.3;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 40px;
    position: relative;
}

.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(0, 245, 212, 0.5);
    animation: glitch 5s infinite;
}

@keyframes glitch {
    0%, 90%, 100% { transform: translate(0); }
    92% { transform: translate(-2px, 1px); }
    94% { transform: translate(2px, -1px); }
    96% { transform: translate(-1px, 2px); }
    98% { transform: translate(1px, -2px); }
}

.tagline {
    color: var(--text-dim);
    font-size: 0.85rem;
    letter-spacing: 0.5em;
    margin-top: 10px;
    text-transform: uppercase;
}

.status-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    font-size: 0.75rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--accent-cyan); }
    50% { opacity: 0.5; box-shadow: 0 0 5px var(--accent-cyan); }
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
}

@media (max-width: 900px) {
    .main-grid { grid-template-columns: 1fr; }
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    background: linear-gradient(90deg, rgba(0, 245, 212, 0.1), transparent);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.panel-header::before {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--accent-cyan);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.panel-body {
    padding: 20px;
}

/* Algorithm Selector */
.algo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.algo-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    padding: 12px 8px;
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.algo-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.algo-btn.active {
    background: rgba(0, 245, 212, 0.1);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 245, 212, 0.2);
}

/* Input Groups */
.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.char-count {
    color: var(--accent-cyan);
}

.input-field {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 15px;
    font-family: inherit;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.3s;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 245, 212, 0.1);
}

.input-field::placeholder {
    color: var(--text-dim);
}

textarea.input-field {
    min-height: 120px;
    resize: vertical;
}

/* Key Input with Strength */
.key-wrapper {
    position: relative;
}

.key-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.3s;
}

.key-toggle:hover {
    color: var(--accent-cyan);
}

.strength-bar {
    height: 3px;
    background: var(--border-color);
    margin-top: 8px;
    border-radius: 2px;
    overflow: hidden;
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: all 0.3s;
    border-radius: 2px;
}

.strength-text {
    font-size: 0.7rem;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Action Buttons */
.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 25px 0;
}

.action-btn {
    padding: 16px 20px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s;
}

.action-btn:hover::before {
    left: 100%;
}

.btn-encrypt {
    background: linear-gradient(135deg, #00f5d4, #00b894);
    color: #000;
}

.btn-encrypt:hover {
    box-shadow: 0 0 30px rgba(0, 245, 212, 0.5);
    transform: translateY(-2px);
}

.btn-decrypt {
    background: linear-gradient(135deg, #f72585, #b5179e);
    color: #fff;
}

.btn-decrypt:hover {
    box-shadow: 0 0 30px rgba(247, 37, 133, 0.5);
    transform: translateY(-2px);
}

/* Output Area */
.output-wrapper {
    position: relative;
}

.output-field {
    width: 100%;
    min-height: 120px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    color: var(--accent-cyan);
    padding: 15px;
    font-family: inherit;
    font-size: 0.85rem;
    border-radius: 4px;
    resize: vertical;
    line-height: 1.6;
}

.output-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.output-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.output-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 20px; }

/* Stats Panel */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 4px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 5px;
}

/* History Panel */
.history-list {
    max-height: 250px;
    overflow-y: auto;
}

.history-item {
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background: rgba(0, 245, 212, 0.05);
    border-left-color: var(--accent-cyan);
}

.history-item.decrypt-type {
    border-left-color: var(--accent-magenta);
}

.history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.history-preview {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-history {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 30px 0;
}

/* Algorithm Info */
.algo-info {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.8;
}

.algo-info strong {
    color: var(--accent-cyan);
}

/* Matrix rain effect for processing */
.matrix-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.matrix-overlay.active {
    display: flex;
}

.processing-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    color: var(--accent-cyan);
    letter-spacing: 0.3em;
    animation: blink 0.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.matrix-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-panel);
    border: 1px solid var(--accent-cyan);
    padding: 15px 30px;
    border-radius: 4px;
    font-size: 0.85rem;
    z-index: 3000;
    transition: transform 0.3s;
    box-shadow: 0 0 30px rgba(0, 245, 212, 0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border-color: var(--accent-magenta);
    box-shadow: 0 0 30px rgba(247, 37, 133, 0.3);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* Mobile adjustments */
@media (max-width: 600px) {
    .logo { font-size: 2rem; letter-spacing: 0.15em; }
    .algo-grid { grid-template-columns: repeat(2, 1fr); }
    .action-row { grid-template-columns: 1fr; }
    .status-bar { flex-wrap: wrap; gap: 15px; }
}
