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

:root {
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.2s ease-in-out;
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --accent-primary: #60a5fa;
    --accent-hover: #3b82f6;
    --success-color: #34d399;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

/* Hacker Mode Colors */
[data-theme="hacker"] {
    --bg-primary: #000000;
    --bg-secondary: #001100;
    --bg-tertiary: #002200;
    --text-primary: #00ff00;
    --text-secondary: #00cc00;
    --text-muted: #009900;
    --border-color: #00ff00;
    --accent-primary: #00ff00;
    --accent-hover: #00dd00;
    --success-color: #00ff00;
    --danger-color: #ff0000;
    --warning-color: #ffff00;
    --shadow-sm: 0 1px 2px 0 rgb(0 255 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 255 0 / 0.2), 0 2px 4px -2px rgb(0 255 0 / 0.2);
    --shadow-lg: 0 10px 15px -3px rgb(0 255 0 / 0.3), 0 4px 6px -4px rgb(0 255 0 / 0.3);
}

/* Retro Terminal Mode Colors */
[data-theme="retro"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffa500;
    --text-secondary: #ff8c00;
    --text-muted: #ff7f50;
    --border-color: #ffa500;
    --accent-primary: #ffa500;
    --accent-hover: #ff8c00;
    --success-color: #00ffff;
    --danger-color: #ff69b4;
    --warning-color: #ffff00;
    --shadow-sm: 0 1px 2px 0 rgb(255 165 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(255 165 0 / 0.2), 0 2px 4px -2px rgb(255 165 0 / 0.2);
    --shadow-lg: 0 10px 15px -3px rgb(255 165 0 / 0.3), 0 4px 6px -4px rgb(255 165 0 / 0.3);
}

/* Font Styles */
[data-font="monospace"] {
    --font-primary: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

[data-font="code"] {
    --font-primary: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
}

[data-font="terminal"] {
    --font-primary: 'Courier New', 'Monaco', 'Lucida Console', monospace;
}

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

/* Modern Clean Background */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.03) 0%, 
        rgba(139, 92, 246, 0.05) 25%,
        rgba(236, 72, 153, 0.03) 50%,
        rgba(245, 158, 11, 0.04) 75%,
        rgba(16, 185, 129, 0.03) 100%
    );
}

/* Hacker Mode Matrix Effect */
[data-theme="hacker"] body::before {
    background: radial-gradient(circle at 50% 50%, rgba(0, 255, 0, 0.1) 0%, transparent 50%);
    animation: matrixPulse 3s ease-in-out infinite;
}

@keyframes matrixPulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.3; }
}

/* Retro Mode Scanlines */
[data-theme="retro"] body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 165, 0, 0.03) 2px,
        rgba(255, 165, 0, 0.03) 4px
    );
    pointer-events: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 3rem;
    backdrop-filter: blur(2px);
    background: rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    margin-top: 1rem;
    padding-left: 2rem;
    padding-right: 2rem;
    box-shadow: var(--shadow-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background-image: url('https://api.iconify.design/fluent-mdl2:code.svg?color=%233b82f6');
    background-size: contain;
    background-repeat: no-repeat;
    animation: float 4s ease-in-out infinite;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
}

[data-theme="hacker"] .logo-icon {
    filter: drop-shadow(0 0 15px var(--accent-primary));
}

[data-theme="retro"] .logo-icon {
    filter: drop-shadow(0 0 10px var(--accent-primary)) sepia(1) hue-rotate(20deg);
}

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

.logo h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    text-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
    position: relative;
}

.version-badge {
    position: absolute;
    top: -8px;
    right: -20px;
    background: var(--accent-primary);
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    animation: pulse 2s ease-in-out infinite;
}

.controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.theme-selector, .font-selector {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.theme-selector:hover, .font-selector:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Auto-Detection Section */
.auto-detect-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.detect-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.detect-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.detected-format {
    padding: 0.25rem 0.75rem;
    background: var(--accent-primary);
    color: white;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
}

.confidence-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.confidence-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--danger-color), var(--warning-color), var(--success-color));
    border-radius: 3px;
    width: var(--confidence, 0%);
    transition: width 0.3s ease;
}

.confidence-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 35px;
}

.override-btn {
    padding: 0.25rem 0.75rem;
    background: var(--warning-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.override-btn:hover {
    opacity: 0.8;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-selector::before {
    content: "Select Format";
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    min-width: 320px;
    z-index: 100;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    user-select: none;
}

[data-theme="dark"] .dropdown-trigger {
    background: rgba(15, 23, 42, 0.95);
}

[data-theme="hacker"] .dropdown-trigger {
    background: rgba(0, 17, 0, 0.95);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

[data-theme="retro"] .dropdown-trigger {
    background: rgba(26, 26, 26, 0.95);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.3);
}

.dropdown-trigger:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.15), 0 0 0 1px rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .dropdown-trigger:hover {
    background: rgba(15, 23, 42, 1);
}

[data-theme="hacker"] .dropdown-trigger:hover {
    background: rgba(0, 17, 0, 1);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

[data-theme="retro"] .dropdown-trigger:hover {
    background: rgba(26, 26, 26, 1);
    box-shadow: 0 0 20px rgba(255, 165, 0, 0.5);
}

.dropdown-trigger.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

.dropdown-arrow {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.dropdown-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(3px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    margin-top: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

[data-theme="dark"] .dropdown-menu {
    background: rgba(15, 23, 42, 0.98);
}

[data-theme="hacker"] .dropdown-menu {
    background: rgba(0, 17, 0, 0.98);
    border-color: var(--accent-primary);
}

[data-theme="retro"] .dropdown-menu {
    background: rgba(26, 26, 26, 0.98);
    border-color: var(--accent-primary);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-group {
    padding: 0.5rem 0;
}

.dropdown-group-header {
    padding: 0.75rem 1.5rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 0.25rem;
    background: rgba(59, 130, 246, 0.05);
}

[data-theme="dark"] .dropdown-group-header {
    background: rgba(59, 130, 246, 0.1);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="hacker"] .dropdown-group-header {
    background: rgba(0, 255, 0, 0.1);
    border-bottom-color: rgba(0, 255, 0, 0.2);
}

[data-theme="retro"] .dropdown-group-header {
    background: rgba(255, 165, 0, 0.1);
    border-bottom-color: rgba(255, 165, 0, 0.2);
}

.dropdown-option {
    padding: 0.875rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: var(--text-primary);
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-option:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    transform: translateX(4px);
    padding-left: 2rem;
}

.dropdown-option.selected {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
    box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.2);
    border-left: 3px solid var(--accent-primary);
}

.dropdown-option.selected::before {
    content: "✓";
    color: var(--accent-primary);
    font-weight: bold;
    margin-right: 0.5rem;
    animation: checkmark 0.3s ease-out;
}

@keyframes checkmark {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 0.5rem 0;
}

/* Cipher Controls */
.cipher-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.shift-label, .key-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.shift-input, .key-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: var(--font-primary);
}

.key-input {
    width: 150px;
    text-align: left;
}

.shift-input:focus, .key-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    background: var(--bg-primary);
    transform: scale(1.05);
}

/* Button Styles */
.btn-primary, .btn-secondary, .btn-tool {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, var(--accent-hover), #1d4ed8);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: var(--accent-primary);
}

.btn-tool {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
}

.btn-tool:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Converter Panel */
.converter-panel {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .converter-panel {
        grid-template-columns: 1fr 1fr;
    }
}

.input-section, .output-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.input-section:hover, .output-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-label {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat {
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.output-tools {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.download-group {
    position: relative;
}

.download-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    display: none;
    z-index: 100;
    min-width: 120px;
}

.download-group:hover .download-menu,
.download-group.active .download-menu {
    display: block;
}

.download-menu button {
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: var(--transition);
}

.download-menu button:hover {
    background: var(--bg-secondary);
}

.input-textarea, .output-textarea {
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 120px;
}

.input-textarea:focus, .output-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    transform: scale(1.02);
}

.output-textarea {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.2);
}

.input-analysis {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.analysis-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.ascii-breakdown {
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 1rem;
    font-family: var(--font-primary);
    font-size: 0.875rem;
    max-height: 200px;
    overflow-y: auto;
}

/* Panels */
.brute-force-panel, .matrix-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.close-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.close-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.brute-force-results {
    padding: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.brute-force-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-family: var(--font-primary);
}

.brute-force-item:hover {
    background: var(--bg-tertiary);
    cursor: pointer;
}

.matrix-display {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
}

.playfair-matrix {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    font-family: var(--font-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.matrix-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: white;
    border-radius: 0.5rem;
    text-transform: uppercase;
}

/* History Section */
.history-section {
    margin-top: 3rem;
}

.history-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-panel {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 1rem;
}

.history-container {
    background: var(--bg-secondary);
    border-radius: 1rem;
    padding: 1.5rem;
    padding-right: 3.5rem;
    min-height: 140px;
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    flex: 1;
}

.clear-history-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 0.6rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    z-index: 10;
    opacity: 0.7;
}

.clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3), 0 0 0 2px rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
    opacity: 1;
}

.clear-history-btn:active {
    transform: translateY(0) scale(0.95);
}

.clear-history-btn span {
    transition: transform 0.2s ease;
}

.clear-history-btn:hover span {
    transform: rotate(15deg);
}

.no-history {
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
    padding: 2rem;
}

.history-item {
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.history-item:hover {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.history-item:last-child {
    margin-bottom: 0;
}

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

.history-mode {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-actions {
    display: flex;
    gap: 0.25rem;
}

.history-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: var(--transition);
}

.history-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.history-btn.starred {
    color: var(--warning-color);
}

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

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

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    text-align: center;
}

.qr-canvas {
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

.share-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    margin-bottom: 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 3rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: 1rem 1rem 0 0;
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.footer a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
    transform: scale(1.05);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 1.25rem 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 250px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
    animation: toastPulse 0.5s ease-out;
}

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

.toast.success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
}

.toast.error {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5), 0 0 30px rgba(59, 130, 246, 0.3);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
        padding: 2rem 1rem;
    }
    
    .logo {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .logo h1 {
        font-size: 1.75rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .control-group {
        justify-content: center;
    }
    
    .mode-selector::before {
        font-size: 1.1rem;
    }
    
    .custom-dropdown {
        min-width: 280px;
    }
    
    .dropdown-trigger {
        font-size: 1rem;
        padding: 0.875rem 1.25rem;
    }
    
    .dropdown-menu {
        max-height: 300px;
        font-size: 0.95rem;
    }
    
    .dropdown-option {
        padding: 0.75rem 1.25rem;
    }
    
    .dropdown-option:hover {
        padding-left: 1.75rem;
    }
    
    .cipher-controls {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
    }
    
    .converter-panel {
        gap: 2rem;
    }
    
    .input-section, .output-section {
        padding: 1.5rem;
        margin: 0 -0.5rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .section-label {
        font-size: 1.2rem;
    }
    
    .text-stats {
        justify-content: center;
    }
    
    .output-tools {
        justify-content: center;
    }
    
    .history-title {
        font-size: 1.3rem;
    }
    
    .history-panel {
        flex-direction: column;
        gap: 0;
    }
    
    .history-container {
        padding-right: 3rem;
    }
    
    .clear-history-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        top: 0.75rem;
        right: 0.75rem;
    }
    
    .auto-detect-section {
        padding: 1rem;
    }
    
    .detect-indicator {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .confidence-meter {
        min-width: auto;
    }
    
    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        min-width: auto;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .dropdown-option {
        padding: 1rem 1.5rem;
        min-height: 48px;
    }
    
    .dropdown-trigger {
        min-height: 48px;
        touch-action: manipulation;
    }
    
    .clear-history-btn {
        width: 44px;
        height: 44px;
        touch-action: manipulation;
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .btn-primary, .btn-secondary {
        min-height: 48px;
        touch-action: manipulation;
    }
    
    .btn-tool {
        width: 44px;
        height: 44px;
    }
}
