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

[hidden] {
    display: none !important;
}

:root {
    --color-bg: #f8f9fb;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-secondary: #6b7280;
    --color-accent: #4f6ef7;
    --color-accent-hover: #3b5de7;
    --color-accent-light: #eef1ff;
    --color-secondary: #6c63ff;
    --color-secondary-hover: #5a52e0;
    --color-border: #e5e7eb;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-error-bg: #fef2f2;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* ===== 3-Column Layout ===== */
.ad-column {
    width: 300px;
    flex-shrink: 0;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
}

.ad-placeholder {
    width: 260px;
    min-height: 600px;
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== Main App ===== */
.app {
    flex: 1;
    max-width: 680px;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* ===== Header ===== */
.app-header {
    text-align: center;
}

.logo {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--color-text);
}

.logo-accent {
    color: var(--color-accent);
}

.tagline {
    margin-top: 8px;
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    font-weight: 400;
}

/* ===== Upload / Drop Zone ===== */
.upload-section {
    width: 100%;
}

.drop-zone {
    width: 100%;
    min-height: 220px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    position: relative;
}

.drop-zone:hover,
.drop-zone:focus-visible {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
    box-shadow: var(--shadow-sm);
    outline: none;
}

.drop-zone.drag-over {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
    box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.15);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px;
}

.drop-zone-icon {
    width: 48px;
    height: 48px;
    color: var(--color-accent);
}

.drop-zone-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
}

.drop-zone-hint {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.drop-zone-formats {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    opacity: 0.7;
    margin-top: 4px;
}

/* ===== Image Preview ===== */
.preview-container {
    width: 100%;
    margin-top: 16px;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.preview-container img {
    width: 100%;
    display: block;
    border-radius: var(--radius-md);
}

.btn-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
}

.btn-remove:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.btn-remove svg {
    width: 18px;
    height: 18px;
}

/* ===== Action Buttons ===== */
.actions-section {
    display: flex;
    gap: 16px;
    width: 100%;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:active {
    transform: scale(0.97);
}

.btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    box-shadow: 0 4px 14px rgba(79, 110, 247, 0.4);
}

.btn-secondary {
    background: var(--color-secondary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.btn-secondary:hover {
    background: var(--color-secondary-hover);
    box-shadow: 0 4px 14px rgba(108, 99, 255, 0.4);
}

.btn-qr {
    background: #0ea5e9;
    color: #fff;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.btn-qr:hover {
    background: #0284c7;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.4);
}

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

/* ===== Loading ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* ===== Results ===== */
.results-section {
    width: 100%;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.results-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-copy:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-accent-light);
}

.btn-copy.copied {
    border-color: var(--color-success);
    color: var(--color-success);
    background: #ecfdf5;
}

.btn-copy svg {
    width: 16px;
    height: 16px;
}

.results-body {
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: var(--color-text);
}

.results-body .url-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: var(--color-accent-light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-accent);
    word-break: break-all;
}

.results-body .url-item a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.results-body .url-item a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.results-body .url-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--color-accent);
}

/* ===== Error ===== */
.error-message {
    width: 100%;
    padding: 14px 20px;
    background: var(--color-error-bg);
    color: var(--color-error);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding-top: 8px;
}

.app-footer p {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

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

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

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 420px;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--color-bg);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

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

.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-ad-placeholder {
    width: 100%;
    min-height: 280px;
    border-radius: var(--radius-md);
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .ad-column {
        display: none;
    }
}

@media (max-width: 600px) {
    .app {
        padding: 24px 16px;
        gap: 24px;
    }

    .logo {
        font-size: 1.7rem;
    }

    .tagline {
        font-size: 0.92rem;
    }

    .drop-zone {
        min-height: 180px;
    }

    .actions-section {
        flex-direction: column;
        gap: 12px;
    }

    .btn {
        padding: 14px 20px;
    }

    .results-body {
        max-height: 300px;
    }

    .modal {
        width: 95%;
        padding: 20px;
    }
}
