/* ============================================
   CSS Design System — TOTP Generator
   Dark minimalist theme with subtle matrix bg
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-card-hover: #1a1a25;
    --bg-input: #1e1e2a;

    --text-primary: #e8e8ef;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --text-code: #00ff88;

    --accent: #00e07b;
    --accent-dim: rgba(0, 224, 123, 0.15);
    --accent-glow: rgba(0, 224, 123, 0.3);
    --accent-hover: #00ff8c;

    --danger: #ff4466;
    --danger-dim: rgba(255, 68, 102, 0.15);

    --telegram: #2AABEE;
    --telegram-hover: #40b8f5;
    --telegram-dim: rgba(42, 171, 238, 0.12);

    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(0, 224, 123, 0.25);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(0, 224, 123, 0.1);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Matrix Canvas --- */
#matrixCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.07;
}

/* --- Language Selector --- */
.lang-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    backdrop-filter: blur(12px);
}

.lang-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.lang-btn.active {
    color: var(--accent);
    background: var(--accent-dim);
}

/* --- Main Container --- */
.container {
    position: relative;
    z-index: 10;
    max-width: 480px;
    margin: 0 auto;
    padding: 60px 20px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

/* --- Header --- */
.header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    color: var(--accent);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 224, 123, 0.15);
    margin-bottom: 4px;
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 224, 123, 0); }
    50% { box-shadow: 0 0 20px 4px rgba(0, 224, 123, 0.08); }
}

.logo-icon svg {
    width: 32px;
    height: 32px;
}

.title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 340px;
}

/* --- Input Section --- */
.input-section {
    width: 100%;
}

.input-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.secret-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-normal);
    letter-spacing: 1px;
    min-width: 0;
}

.secret-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-main);
    letter-spacing: 0;
    font-size: 0.85rem;
}

.secret-input:focus {
    border-color: var(--border-accent);
    box-shadow: 0 0 0 3px var(--accent-dim), var(--shadow-sm);
}

.btn-generate {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 22px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.btn-generate:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

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

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-hint::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.5;
}

/* --- Code Section --- */
.code-section {
    width: 100%;
    transition: all var(--transition-slow);
}

.code-section.hidden {
    display: none;
}

.code-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
    animation: cardAppear 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.code-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

/* --- Timer --- */
.timer-container {
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 226.2;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
    filter: drop-shadow(0 0 4px var(--accent-glow));
}

.timer-ring-progress.warning {
    stroke: #ffaa00;
    filter: drop-shadow(0 0 4px rgba(255, 170, 0, 0.3));
}

.timer-ring-progress.critical {
    stroke: var(--danger);
    filter: drop-shadow(0 0 4px rgba(255, 68, 102, 0.3));
}

.timer-text {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    z-index: 1;
}

.timer-text.warning {
    color: #ffaa00;
}

.timer-text.critical {
    color: var(--danger);
    animation: timerBlink 0.6s ease-in-out infinite;
}

@keyframes timerBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Code Display --- */
.code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 8px 16px;
    border-radius: var(--radius-md);
}

.code-display:hover {
    background: rgba(0, 224, 123, 0.05);
}

.code-digits {
    font-family: var(--font-mono);
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-code);
    letter-spacing: 8px;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
    user-select: all;
}

/* --- Copy Button --- */
.btn-copy {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    border: 1px solid rgba(0, 224, 123, 0.15);
    border-radius: var(--radius-md);
    padding: 10px 20px;
    color: var(--accent);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-copy:hover {
    background: rgba(0, 224, 123, 0.2);
    border-color: rgba(0, 224, 123, 0.3);
    transform: translateY(-1px);
}

.btn-copy .hidden {
    display: none;
}

.btn-copy.copied {
    background: rgba(0, 224, 123, 0.25);
    border-color: var(--accent);
}

/* --- Progress Bar --- */
.progress-bar-container {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 1s linear, background-color 0.3s ease;
    box-shadow: 0 0 8px var(--accent-glow);
}

.progress-bar.warning {
    background: #ffaa00;
    box-shadow: 0 0 8px rgba(255, 170, 0, 0.3);
}

.progress-bar.critical {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(255, 68, 102, 0.3);
}

/* --- Error Message --- */
.error-message {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--danger-dim);
    border: 1px solid rgba(255, 68, 102, 0.2);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    color: var(--danger);
    font-size: 0.85rem;
    width: 100%;
    animation: errorShake 0.4s ease;
}

.error-message.hidden {
    display: none;
}

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

/* --- Telegram Button --- */
.shop-section {
    width: 100%;
}

.btn-telegram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--telegram-dim);
    border: 1px solid rgba(42, 171, 238, 0.15);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    color: var(--telegram);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-telegram:hover {
    background: rgba(42, 171, 238, 0.18);
    border-color: rgba(42, 171, 238, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(42, 171, 238, 0.1);
}

.btn-telegram .arrow-icon {
    transition: transform var(--transition-normal);
}

.btn-telegram:hover .arrow-icon {
    transform: translateX(3px);
}

.tg-icon {
    flex-shrink: 0;
}

/* --- Footer --- */
.footer {
    text-align: center;
}

.footer-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* --- Responsive --- */
@media (max-width: 520px) {
    .container {
        padding: 50px 16px 30px;
        gap: 24px;
    }

    .title {
        font-size: 1.35rem;
    }

    .subtitle {
        font-size: 0.82rem;
    }

    .input-group {
        flex-direction: column;
    }

    .btn-generate {
        width: 100%;
        padding: 14px;
    }

    .code-digits {
        font-size: 2.2rem;
        letter-spacing: 6px;
    }

    .code-card {
        padding: 24px 18px;
    }

    .lang-selector {
        top: 12px;
        right: 12px;
    }

    .lang-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 360px) {
    .code-digits {
        font-size: 1.8rem;
        letter-spacing: 4px;
    }
}

/* --- Animations --- */
.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

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

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

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

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

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