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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #f8fafc;
    --accent-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a4d3a 0%, #0f2419 50%, #051a0f 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    animation: glow 3s ease-in-out infinite;
}

.logo i {
    font-size: 2.5rem;
    color: white;
    background: var(--primary-color);
    padding: 0.75rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tagline {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    animation: fadeInUp 1s ease-out 0.4s both;
}

/* Shortener Section */
.shortener-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}

.input-container {
    max-width: 600px;
    margin: 0 auto;
    animation: bounceIn 0.8s ease-out 0.6s both;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--secondary-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
    animation: pulse 0.6s ease-in-out;
}

.input-icon {
    color: var(--text-light);
    margin-left: 0.75rem;
    font-size: 1.125rem;
}

.url-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
}

.url-input::placeholder {
    color: var(--text-light);
}

.shorten-btn {
    background: linear-gradient(135deg, #1a4d3a 0%, #0f2419 50%, #051a0f 100%);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.shorten-btn::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;
}

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

.shorten-btn:hover {
    background: linear-gradient(135deg, #2a5d4a 0%, #1f3429 50%, #152a1f 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(26, 77, 58, 0.3);
}

.shorten-btn:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

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

.shorten-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    display: none;
    animation: shake 0.5s ease-in-out;
}

.error-message.show {
    display: block;
    animation: shake 0.5s ease-in-out, fadeInUp 0.3s ease-out;
}

/* Result Section */
.result-section {
    display: none;
}

.result-section.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

/* Enhanced Animations and Transitions */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(26, 77, 58, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(26, 77, 58, 0.6), 0 0 30px rgba(26, 77, 58, 0.4);
    }
    100% {
        box-shadow: 0 0 5px rgba(26, 77, 58, 0.3);
    }
}

.result-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
    animation: bounceIn 0.6s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.success-icon {
    color: var(--accent-color);
    font-size: 1.5rem;
}

.result-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.url-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
}

.short-url-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem;
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
    outline: none;
}

.copy-btn {
    background: linear-gradient(135deg, #1a4d3a 0%, #0f2419 50%, #051a0f 100%);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.copy-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.copy-btn:active::after {
    width: 200px;
    height: 200px;
}

.copy-btn:hover {
    background: linear-gradient(135deg, #2a5d4a 0%, #1f3429 50%, #152a1f 100%);
    transform: scale(1.1) rotate(5deg);
}

.url-info {
    margin-bottom: 1.5rem;
}

.original-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--border-light);
    border-radius: var(--radius-md);
}

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

.url-text {
    color: var(--text-primary);
    font-size: 0.875rem;
    word-break: break-all;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.visit-btn, .qr-btn {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.visit-btn {
    background: linear-gradient(135deg, #1a4d3a 0%, #0f2419 50%, #051a0f 100%);
    color: white;
}

.visit-btn:hover {
    background: linear-gradient(135deg, #2a5d4a 0%, #1f3429 50%, #152a1f 100%);
    transform: translateY(-1px);
}

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

.qr-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

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

.qr-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

.qr-container canvas {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.download-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.download-btn:hover {
    background: var(--primary-dark);
}

/* History Section */
.history-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}

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

.history-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-btn {
    background: linear-gradient(135deg, #1a4d3a 0%, #0f2419 50%, #051a0f 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-btn:hover {
    background: linear-gradient(135deg, #2a5d4a 0%, #1f3429 50%, #152a1f 100%);
    transform: translateY(-1px);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.history-item {
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.5s ease-out;
    transform: translateY(0);
}

.history-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.1);
    transform: translateY(-3px) scale(1.02);
}

.history-item:nth-child(even) {
    animation-delay: 0.1s;
}

.history-item:nth-child(odd) {
    animation-delay: 0.2s;
}

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

.history-short-url {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    word-break: break-all;
}

.history-short-url:hover {
    text-decoration: underline;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.history-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}

.history-btn:hover {
    background: var(--border-color);
}

.history-original {
    font-size: 0.875rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--accent-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .shortener-section,
    .result-card,
    .history-section {
        padding: 1.5rem;
    }

    .input-wrapper {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .shorten-btn {
        justify-content: center;
        padding: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .visit-btn, .qr-btn {
        min-width: auto;
    }

    .history-header {
        flex-direction: column;
        align-items: stretch;
    }

    .history-item-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .history-actions {
        align-self: flex-start;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo i {
        font-size: 2rem;
        padding: 0.5rem;
    }

    .logo h1 {
        font-size: 1.75rem;
    }

    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
}

/* Loading Animation */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Utility Classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}