/* ========================================
   CSS Variables & Root Styles
======================================== */
:root {
    /* Primary Colors */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;

    /* Accent Colors */
    --accent-cyan: #00d4ff;
    --accent-pink: #ff6b9d;
    --accent-green: #00e676;
    --accent-orange: #ff9100;

    /* Neutral Colors */
    --bg-dark: #0a0a1a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);

    /* Telegram Theme Colors (will be overridden by Telegram) */
    --tg-theme-bg-color: #0a0a1a;
    --tg-theme-text-color: #ffffff;
    --tg-theme-button-color: #667eea;
    --tg-theme-button-text-color: #ffffff;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.3);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ========================================
   Reset & Base Styles
======================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-theme-bg-color, var(--bg-dark));
    color: var(--tg-theme-text-color, var(--text-primary));
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-cyan);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

/* ========================================
   Background Effects
======================================== */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: var(--primary-color);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: var(--secondary-color);
    bottom: 10%;
    left: -80px;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: var(--accent-cyan);
    top: 50%;
    right: -50px;
    animation-delay: -14s;
    opacity: 0.3;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(20px, -30px) scale(1.1);
    }

    50% {
        transform: translate(-10px, 20px) scale(0.95);
    }

    75% {
        transform: translate(30px, 10px) scale(1.05);
    }
}

.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-cyan);
    border-radius: 50%;
    opacity: 0;
    animation: particle-float 4s ease-in-out infinite;
}

@keyframes particle-float {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
        transform: translateY(-20vh) scale(1);
    }
}

/* ========================================
   Container & Layout
======================================== */
.container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    max-width: 480px;
    margin: 0 auto;
}

/* ========================================
   Header
======================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(0, 230, 118, 0.1);
    border: 1px solid rgba(0, 230, 118, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-green);
}

.security-badge svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Main Content
======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* ========================================
   Card Styles
======================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all var(--transition-normal);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.hidden {
    display: none !important;
}

/* ========================================
   Input Card
======================================== */
.input-card {
    text-align: center;
}

.input-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.input-title svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.input-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-lg);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 var(--spacing-md);
    transition: all var(--transition-normal);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.input-wrapper svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: var(--spacing-md) var(--spacing-sm);
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: inherit;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-clear-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.input-clear-btn:hover {
    background: rgba(255, 107, 157, 0.2);
}

.input-clear-btn svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.input-error {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 107, 157, 0.1);
    border: 1px solid rgba(255, 107, 157, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--accent-pink);
    text-align: left;
}

.input-error svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ========================================
   Result Card
======================================== */
.result-card {
    text-align: center;
}

.result-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.result-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-icon.success {
    background: rgba(0, 230, 118, 0.15);
    border: 2px solid var(--accent-green);
}

.result-icon.success svg {
    width: 28px;
    height: 28px;
    color: var(--accent-green);
}

.result-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-green);
}

.result-link-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.result-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
    text-align: left;
}

.result-link-wrapper {
    display: flex;
    gap: var(--spacing-sm);
}

.generated-link {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.85rem;
    color: var(--accent-cyan);
    font-family: monospace;
    text-decoration: none;
    word-break: break-all;
    display: block;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    z-index: 10;
}

.generated-link:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--accent-cyan);
    color: #00ffff;
    text-decoration: underline;
}

.copy-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
}

.copy-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.copy-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* ========================================
   Recent Links Card
======================================== */
.recent-card {
    background: rgba(255, 255, 255, 0.03);
}

.recent-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.recent-title svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.recent-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.recent-url {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: var(--spacing-sm);
}

.recent-copy-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.recent-copy-btn:hover {
    background: rgba(102, 126, 234, 0.3);
}

.recent-copy-btn svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

/* ========================================
   Loading Card
======================================== */
.loading-card {
    text-align: center;
    padding: var(--spacing-2xl);
}

.loading-animation {
    margin-bottom: var(--spacing-lg);
}

.link-chain {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.chain-link {
    width: 50px;
    height: 50px;
    border: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    position: relative;
}

.chain-1 {
    animation: chain-pulse 1.5s ease-in-out infinite;
}

.chain-2 {
    animation: chain-pulse 1.5s ease-in-out infinite 0.3s;
}

.chain-connector {
    width: 30px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-cyan));
    animation: connector-glow 1.5s ease-in-out infinite;
}

@keyframes chain-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes connector-glow {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
        box-shadow: 0 0 20px var(--accent-cyan);
    }
}

.loading-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.loading-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========================================
   Transit Card
======================================== */
.transit-card {
    text-align: center;
}

.destination-preview {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.preview-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.preview-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.preview-info {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.preview-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.preview-url {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Countdown Section */
.countdown-section {
    margin-bottom: var(--spacing-lg);
}

.countdown-ring {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto var(--spacing-md);
}

.countdown-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.countdown-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 6;
}

.countdown-progress {
    fill: none;
    stroke: url(#countdown-gradient);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.countdown-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.countdown-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.countdown-text span {
    color: var(--accent-cyan);
    font-weight: 600;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-normal);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(102, 126, 234, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Link Info */
.link-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

.info-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.info-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.info-item strong {
    color: var(--text-secondary);
}

/* ========================================
   Advertisement Section
======================================== */
.ad-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.ad-label {
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
}

.ad-label span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.ad-container {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
}

/* ========================================
   Error Card
======================================== */
.error-card {
    text-align: center;
    padding: var(--spacing-2xl);
}

.error-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-lg);
    background: rgba(255, 107, 157, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-icon svg {
    width: 40px;
    height: 40px;
    color: var(--accent-pink);
}

.error-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--accent-pink);
}

.error-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   Footer
======================================== */
.footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    margin-top: auto;
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-size: 0.75rem;
}

.footer-links a {
    color: var(--text-muted);
}

.footer-links a:hover {
    color: var(--accent-cyan);
}

.footer-links span {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ========================================
   Toast Notification
======================================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--accent-green);
    color: #0a0a1a;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Responsive Adjustments
======================================== */
@media (max-width: 360px) {
    :root {
        --spacing-md: 12px;
        --spacing-lg: 20px;
    }

    .countdown-ring {
        width: 100px;
        height: 100px;
    }

    .countdown-number {
        font-size: 2rem;
    }
}

/* ========================================
   Animations
======================================== */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fade-in 0.5s ease-out;
}

.card.shake {
    animation: shake 0.5s ease-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-10px);
    }

    40% {
        transform: translateX(10px);
    }

    60% {
        transform: translateX(-10px);
    }

    80% {
        transform: translateX(10px);
    }
}

/* Gradient for countdown ring */
svg defs {
    display: block;
}