/* ==========================================================================
   ShortLink Design System & Styles
   Modern Dark Glassmorphism Theme
   ========================================================================== */

:root {
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Color Palette */
    --bg-dark: #090d16;
    --card-bg: rgba(18, 26, 43, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-hover: rgba(99, 102, 241, 0.3);

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);

    --accent: #8b5cf6;
    --accent-hover: #7c3aed;

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.12);
    --input-focus: #6366f1;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Background Glow Effects */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: floatBlob 12s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, #6366f1, #3b82f6);
}

.blob-2 {
    bottom: -15%;
    right: -10%;
    width: 45vw;
    height: 45vw;
    background: radial-gradient(circle, #8b5cf6, #ec4899);
    animation-delay: -6s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 40px) scale(1.1); }
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* Header */
.site-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.6));
    animation: pulse 2s infinite ease-in-out;
}

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

.logo-text .highlight {
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version-badge {
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-primary);
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    transform: translateY(-8px);
}

.tagline {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 540px;
    margin: 0 auto;
}

/* Glassmorphism Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--card-border-hover);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

/* Forms & Inputs */
.shorten-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.1rem;
    font-size: 1.1rem;
    pointer-events: none;
    opacity: 0.7;
}

input[type="text"],
input[type="url"] {
    width: 100%;
    padding: 1rem 1.2rem 1rem 3rem;
    font-size: 1rem;
    font-family: var(--font-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="url"]:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    background: rgba(15, 23, 42, 0.85);
}

input::placeholder {
    color: var(--text-subtle);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.9rem 1.6rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.btn-accent {
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.btn-accent:hover {
    background: rgba(139, 92, 246, 0.35);
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-danger-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
}

.btn-danger-sm:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
}

.btn-icon-sm {
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
    transition: var(--transition);
}

.btn-link:hover {
    color: var(--primary);
}

/* Options & Grid */
.options-toggle {
    display: flex;
    justify-content: flex-start;
}

.advanced-options {
    background: rgba(15, 23, 42, 0.4);
    border: 1px dashed var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    animation: fadeIn 0.3s ease;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .input-group {
        flex-direction: column;
    }
    .btn-primary {
        width: 100%;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-field label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.alias-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.alias-prefix {
    padding-left: 0.9rem;
    font-size: 0.85rem;
    color: var(--text-subtle);
    user-select: none;
    white-space: nowrap;
}

.alias-input-wrapper input {
    border: none;
    border-radius: 0;
    padding-left: 0.3rem;
    background: transparent;
}

/* Result Box */
.result-box {
    margin-top: 1.5rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 1.2rem 1.5rem;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-header {
    font-weight: 700;
    color: var(--success);
    margin-bottom: 0.8rem;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

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

.short-link-display {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    word-break: break-all;
    transition: var(--transition);
}

.short-link-display:hover {
    color: #a5b4fc;
}

.original-url-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 450px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.2rem;
}

.result-actions {
    display: flex;
    gap: 0.6rem;
}

/* Messages & Alerts */
.message-box {
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1rem;
}

.message-box.error {
    background: var(--danger-bg);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.message-box.success {
    background: var(--success-bg);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 1.4rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--text-main);
}

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

.history-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
}

.search-box {
    position: relative;
    min-width: 250px;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
    font-size: 0.9rem;
}

.search-box input {
    padding: 0.6rem 1rem 0.6rem 2.4rem;
    font-size: 0.9rem;
    border-radius: var(--radius-full);
}

/* Link Cards List */
.links-container {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.link-item {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: var(--transition);
}

.link-item:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateX(4px);
}

.link-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1;
}

.link-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.link-short-url {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: #818cf8;
    text-decoration: none;
}

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

.link-custom-badge {
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-full);
}

.link-original {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.78rem;
    color: var(--text-subtle);
    margin-top: 0.2rem;
}

.clicks-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
}

.link-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

/* Modal Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 2rem;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), var(--shadow-glow);
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    0% { transform: scale(0.9) translateY(20px); }
    100% { transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1.8rem;
}

.qr-preview-box {
    background: #ffffff;
    padding: 1.2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qr-url-text {
    font-family: monospace;
    font-size: 0.9rem;
    color: #a5b4fc;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    word-break: break-all;
    text-align: center;
}

.modal-footer {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

.modal-footer .btn {
    flex: 1;
}

/* Spinner & Utility */
.hidden {
    display: none !important;
}

.loading-spinner {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.8rem;
}

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

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

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

/* Footer */
.site-footer {
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.85rem;
    margin-top: 2rem;
}
