/* ===== Design System ===== */
:root {
    /* Colors */
    --color-primary: #667eea;
    --color-primary-dark: #5a67d8;
    --color-secondary: #764ba2;
    --color-accent: #f093fb;
    --color-success: #48bb78;
    --color-error: #f56565;

    /* Neutrals */
    --color-bg: #0f0f1e;
    --color-bg-light: #1a1a2e;
    --color-bg-lighter: #252538;
    --color-surface: rgba(255, 255, 255, 0.05);
    --color-surface-hover: rgba(255, 255, 255, 0.08);
    --color-text: #ffffff;
    --color-text-secondary: #a0aec0;
    --color-text-muted: #718096;
    --color-border: rgba(255, 255, 255, 0.1);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-mesh: radial-gradient(at 0% 0%, rgba(102, 126, 234, 0.2) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(118, 75, 162, 0.2) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(240, 147, 251, 0.2) 0, transparent 50%);

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Background Elements ===== */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-mesh);
    z-index: -2;
    opacity: 0.6;
}

.bg-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(240, 147, 251, 0.1) 0%, transparent 50%);
    z-index: -1;
    animation: meshMove 20s ease-in-out infinite;
}

@keyframes meshMove {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* ===== Container ===== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: var(--space-lg);
    animation: fadeInDown 0.6s ease;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.logo svg {
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.4));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.logo h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

/* ===== Mode Toggle ===== */
.mode-toggle {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: 0.375rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.6s ease 0.1s both;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.mode-btn:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.mode-btn.active {
    background: var(--gradient-primary);
    color: var(--color-text);
    box-shadow: var(--shadow-glow);
}

.mode-btn svg {
    transition: transform var(--transition-base);
}

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

/* ===== Card ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.6s ease 0.2s both;
}

/* ===== Form Elements ===== */
.input-section {
    margin-bottom: var(--space-md);
}

.label {
    display: block;
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--space-xs);
    letter-spacing: 0.025em;
}

.textarea,
.input {
    width: 100%;
    padding: var(--space-md);
    background: var(--color-bg-lighter);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    resize: vertical;
}

.textarea {
    min-height: 90px;
    line-height: 1.5;
}

.textarea:focus,
.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.textarea::placeholder,
.input::placeholder {
    color: var(--color-text-muted);
}

/* ===== Password Wrapper ===== */
.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.toggle-password:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

/* ===== Buttons ===== */
.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.btn-primary:hover::before {
    left: 100%;
}

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

.btn-primary svg {
    transition: transform var(--transition-base);
}

.btn-primary:hover svg {
    transform: translateX(4px);
}

/* ===== Output Section ===== */
.output-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
    animation: fadeInUp 0.4s ease;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-copy:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-primary);
}

.btn-copy.copied {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

.output-content {
    padding: var(--space-md);
    background: var(--color-bg-lighter);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: 'Courier New', monospace;
    font-size: var(--font-size-sm);
    word-break: break-all;
    line-height: 1.6;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
}

/* ===== Info Card ===== */
.info-card {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.6s ease 0.3s both;
}

.info-card h2 {
    font-size: var(--font-size-base);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

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

.info-card li {
    padding-left: var(--space-md);
    margin-bottom: var(--space-xs);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    position: relative;
}

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

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

/* ===== Footer ===== */
.footer {
    text-align: center;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    animation: fadeIn 0.6s ease 0.4s both;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== 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);
    }
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-lighter);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: var(--radius-sm);
}

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

/* ===== Responsive Design ===== */
@media (max-width: 640px) {
    :root {
        font-size: 14px;
    }

    body {
        overflow-x: hidden;
    }

    .container {
        padding: var(--space-sm) var(--space-sm);
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .header {
        margin-bottom: var(--space-sm);
    }

    .logo {
        margin-bottom: 0;
    }

    .logo svg {
        width: 24px;
        height: 24px;
    }

    .logo h1 {
        font-size: var(--font-size-xl);
    }

    .tagline {
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }

    .mode-toggle {
        margin-bottom: var(--space-sm);
        padding: 0.25rem;
    }

    .mode-btn {
        font-size: var(--font-size-sm);
        padding: var(--space-xs) var(--space-sm);
        gap: 0.25rem;
    }

    .mode-btn svg {
        width: 16px;
        height: 16px;
    }

    .card {
        padding: var(--space-md);
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .input-section {
        margin-bottom: var(--space-sm);
    }

    .label {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .textarea {
        min-height: 70px;
        padding: var(--space-sm);
        font-size: 0.875rem;
    }

    .input {
        padding: var(--space-sm);
        font-size: 0.875rem;
    }

    .btn-primary {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }

    .output-section {
        margin-top: var(--space-md);
        padding-top: var(--space-md);
    }

    .output-content {
        min-height: 60px;
        max-height: 120px;
        padding: var(--space-sm);
        font-size: 0.75rem;
    }

    .info-card {
        display: none;
    }

    .footer {
        margin-top: var(--space-md);
        padding-top: var(--space-sm);
        font-size: 0.7rem;
    }
}

@media (max-width: 400px) {
    .output-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .btn-copy {
        align-self: flex-end;
    }
}

/* Mobile viewport optimization */
@media (max-height: 700px) and (max-width: 640px) {
    .container {
        padding: 0.5rem var(--space-sm);
    }

    .header {
        margin-bottom: 0.5rem;
    }

    .mode-toggle {
        margin-bottom: 0.5rem;
    }

    .card {
        padding: var(--space-sm);
    }

    .textarea {
        min-height: 60px;
    }

    .footer {
        display: none;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Focus Visible ===== */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}