/* ============================================================
   LinkGen — Premium Dark Theme
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
    /* Background */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.85);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #38bdf8;

    /* Accent gradients */
    --gradient-primary: linear-gradient(135deg, #06b6d4, #8b5cf6, #ec4899);
    --gradient-btn: linear-gradient(135deg, #06b6d4, #8b5cf6);
    --gradient-btn-hover: linear-gradient(135deg, #22d3ee, #a78bfa);
    --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(6, 182, 212, 0.3);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(6, 182, 212, 0.15);

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

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 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: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}


/* ---- Animated Background ---- */
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.12;
    animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb:nth-child(1) {
    width: 500px;
    height: 500px;
    background: #06b6d4;
    top: -10%;
    left: -5%;
    animation-delay: 0s;
    animation-duration: 25s;
}

.bg-orb:nth-child(2) {
    width: 400px;
    height: 400px;
    background: #8b5cf6;
    top: 50%;
    right: -10%;
    animation-delay: -5s;
    animation-duration: 20s;
}

.bg-orb:nth-child(3) {
    width: 350px;
    height: 350px;
    background: #ec4899;
    bottom: -10%;
    left: 30%;
    animation-delay: -10s;
    animation-duration: 22s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 40px) scale(0.95); }
    75% { transform: translate(30px, 20px) scale(1.02); }
}


/* ---- Layout ---- */
.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}


/* ---- Navbar ---- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.navbar-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: white;
}

.navbar-title {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.navbar-user-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}


/* ---- View Transitions ---- */
.view {
    display: none;
    animation: fadeSlideIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

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


/* ---- Login View ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
    animation: fadeSlideIn 0.5s ease forwards;
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    width: 56px;
    height: 56px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(6, 182, 212, 0.2);
}

.login-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}


/* ---- Form Elements ---- */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-accent);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

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

.form-input-icon {
    position: relative;
}

.form-input-icon .form-input {
    padding-left: 44px;
}

.form-input-icon .icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}


/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-btn);
    color: white;
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.25);
}

.btn-primary:hover {
    background: var(--gradient-btn-hover);
    box-shadow: 0 6px 24px rgba(6, 182, 212, 0.35);
    transform: translateY(-1px);
}

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

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

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

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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


/* ---- Dashboard ---- */
.dashboard {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.dashboard-header {
    margin-bottom: 32px;
}

.dashboard-header h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.dashboard-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}


/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .icon {
    font-size: 20px;
}


/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.05);
}

.upload-zone:hover::before,
.upload-zone.drag-over::before {
    opacity: 0.03;
}

.upload-zone.drag-over {
    transform: scale(1.01);
    box-shadow: var(--shadow-glow);
}

.upload-zone-content {
    position: relative;
    z-index: 1;
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.7;
}

.upload-zone h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 13px;
}

.upload-zone .browse-link {
    color: var(--text-accent);
    text-decoration: underline;
    cursor: pointer;
}

.file-selected {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(6, 182, 212, 0.05);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

.file-selected.visible {
    display: flex;
}

.file-selected .file-icon {
    font-size: 24px;
}

.file-selected .file-info {
    flex: 1;
    min-width: 0;
}

.file-selected .file-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-selected .file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.file-selected .file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    transition: color var(--transition-fast);
}

.file-selected .file-remove:hover {
    color: #ef4444;
}


/* ---- Result Card ---- */
.result-card {
    display: none;
    background: rgba(6, 182, 212, 0.05);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: 20px;
    animation: fadeSlideIn 0.3s ease forwards;
}

.result-card.visible {
    display: block;
}

.result-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #06b6d4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-url {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.result-url a {
    flex: 1;
    color: var(--text-accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    text-decoration: none;
    word-break: break-all;
}

.result-url a:hover {
    text-decoration: underline;
}

.btn-copy {
    background: var(--gradient-btn);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-copy:hover {
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.3);
}

.btn-copy.copied {
    background: linear-gradient(135deg, #10b981, #059669);
}


/* ---- Pages Section ---- */
.pages-section {
    margin-top: 8px;
}

.pages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.pages-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pages-count {
    background: var(--gradient-btn);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.page-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition-base);
    animation: fadeSlideIn 0.3s ease forwards;
}

.page-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.page-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.page-slug {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.page-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
}

.page-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.page-url-row a {
    flex: 1;
    color: var(--text-accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    text-decoration: none;
    word-break: break-all;
    min-width: 0;
}

.page-url-row a:hover {
    text-decoration: underline;
}

.page-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
}

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

.btn-icon.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}


/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}


/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 440px;
    animation: toastSlideIn 0.3s ease forwards;
    backdrop-filter: blur(20px);
}

.toast.removing {
    animation: toastSlideOut 0.25s ease forwards;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast.success {
    border-left: 3px solid #10b981;
}

.toast.error {
    border-left: 3px solid #ef4444;
}

.toast.info {
    border-left: 3px solid #3b82f6;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
}


/* ---- Confirm Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: fadeSlideIn 0.3s ease;
}

.modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

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


/* ---- Loading Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-input) 25%,
        rgba(255, 255, 255, 0.06) 50%,
        var(--bg-input) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 140px;
    border-radius: var(--radius-md);
}


/* ---- Responsive ---- */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
    }

    .dashboard {
        padding: 20px 16px 48px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .pages-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }

    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .dashboard-header h2 {
        font-size: 22px;
    }

    .upload-zone {
        padding: 28px 16px;
    }

    .page-url-row {
        flex-direction: column;
        align-items: stretch;
    }

    .page-url-row .page-actions {
        justify-content: flex-end;
    }
}
