/* ============================================
   Link Masking Application - Stylesheet
   Premium dark theme with glassmorphism
   ============================================ */

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

/* ---- CSS Variables / Design Tokens ---- */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111127;
    --bg-card: rgba(22, 22, 50, 0.7);
    --bg-card-hover: rgba(30, 30, 65, 0.8);
    --bg-input: rgba(15, 15, 40, 0.6);
    --bg-input-focus: rgba(20, 20, 50, 0.8);

    --border-color: rgba(102, 126, 234, 0.15);
    --border-focus: rgba(102, 126, 234, 0.5);
    --border-card: rgba(255, 255, 255, 0.06);

    --text-primary: #e8e8f0;
    --text-secondary: #8b8ba7;
    --text-muted: #5a5a7a;
    --text-label: #b0b0cc;

    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-glow: rgba(102, 126, 234, 0.3);

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

    --fb-blue: #1877f2;
    --fb-bg: #ffffff;
    --fb-text: #050505;
    --fb-text-secondary: #65676b;
    --fb-border: #dadde1;

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

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.15);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ---- Animated Background ---- */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

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

.bg-animation .orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.3), transparent);
    top: -10%;
    left: -5%;
    animation-duration: 25s;
}

.bg-animation .orb:nth-child(2) {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(118, 75, 162, 0.25), transparent);
    top: 50%;
    right: -5%;
    animation-duration: 30s;
    animation-delay: -5s;
}

.bg-animation .orb:nth-child(3) {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15), transparent);
    bottom: -5%;
    left: 30%;
    animation-duration: 22s;
    animation-delay: -10s;
}

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

/* ---- App Container ---- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* ---- Header ---- */
.app-header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease;
}

.app-header .logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.app-header .logo-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-glow);
}

.app-header h1 {
    font-size: 28px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.app-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ---- Main Layout ---- */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* ---- Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 32px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    animation: fadeInUp 0.6s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-header .icon {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ---- Form ---- */
.form-group {
    margin-bottom: 22px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

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

.form-input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 1;
}

.form-input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: all var(--transition-fast);
    outline: none;
}

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

.form-input:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input:focus + .input-icon,
.form-input:focus ~ .input-icon {
    opacity: 1;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

/* ---- Submit Button ---- */
.btn-submit {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    margin-top: 28px;
    letter-spacing: 0.3px;
}

.btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

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

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

.btn-submit .spinner {
    display: inline-block;
    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;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* ---- Facebook Preview ---- */
.fb-preview-container {
    position: sticky;
    top: 30px;
}

.fb-preview-wrapper {
    background: var(--fb-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--fb-border);
}

.fb-preview-image {
    width: 100%;
    height: 260px;
    background: #e4e6eb;
    position: relative;
    overflow: hidden;
}

.fb-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--transition-normal);
}

.fb-preview-image .placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #bcc0c4;
    font-size: 48px;
    flex-direction: column;
    gap: 8px;
}

.fb-preview-image .placeholder span {
    font-size: 13px;
}

.fb-preview-image .play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.fb-preview-image:hover .play-btn {
    opacity: 1;
}

.fb-preview-image .play-btn svg {
    width: 24px;
    height: 24px;
    fill: white;
    margin-left: 3px;
}

.fb-preview-info {
    padding: 12px 16px;
    border-top: 1px solid var(--fb-border);
    background: #f0f2f5;
}

.fb-preview-site {
    font-size: 12px;
    color: var(--fb-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.fb-preview-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--fb-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fb-preview-desc {
    font-size: 13px;
    color: var(--fb-text-secondary);
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Result Section ---- */
.result-section {
    display: none;
    margin-top: 24px;
    animation: fadeInUp 0.4s ease;
}

.result-section.active {
    display: block;
}

.result-box {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    padding: 16px;
}

.result-box .result-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.result-url {
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-url input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', monospace;
    font-size: 13px;
    outline: none;
}

.btn-copy {
    padding: 10px 16px;
    background: var(--success);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-copy:hover {
    background: #059669;
    transform: translateY(-1px);
}

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

/* ---- Links Table Section ---- */
.links-section {
    margin-top: 40px;
    animation: fadeInUp 0.6s ease 0.2s both;
}

.links-section .card {
    padding: 0;
    overflow: hidden;
}

.links-section .card-header {
    padding: 24px 28px 16px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
}

.links-table-wrapper {
    overflow-x: auto;
}

.links-table {
    width: 100%;
    border-collapse: collapse;
}

.links-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
}

.links-table td {
    padding: 14px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.links-table tr:hover td {
    background: rgba(102, 126, 234, 0.03);
}

.links-table .title-cell {
    color: var(--text-primary);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.links-table .url-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
}

.links-table .url-cell a {
    color: var(--accent-primary);
    text-decoration: none;
}

.links-table .url-cell a:hover {
    text-decoration: underline;
}

.links-table .click-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-primary);
}

.links-table .actions-cell {
    display: flex;
    gap: 6px;
}

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-action.copy {
    background: rgba(102, 126, 234, 0.1);
    color: var(--accent-primary);
}

.btn-action.copy:hover {
    background: rgba(102, 126, 234, 0.2);
}

.btn-action.delete {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-action.delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

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

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

/* ---- Toast Notification ---- */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* ---- Selection ---- */
::selection {
    background: rgba(102, 126, 234, 0.3);
    color: white;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .app-container {
        padding: 20px 16px 40px;
    }

    .app-header h1 {
        font-size: 22px;
    }

    .card {
        padding: 24px 20px;
    }

    .result-url {
        flex-direction: column;
    }

    .result-url input,
    .btn-copy {
        width: 100%;
    }

    .links-table th,
    .links-table td {
        padding: 10px 14px;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}
