/* --- THEME DEFINITIONS --- */
/* The theme is selected by applying a class like "theme-purple" to the <html> tag. */

/* Default Theme: Purple */
:root.theme-purple {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --secondary-color: #03dac6;
    --text-color: #e1e1e1;
    --text-muted-color: #888;
}

/* Orange Theme */
:root.theme-orange {
    --bg-color: #1a1a1a;
    --surface-color: #2c2c2c;
    --primary-color: #ff9800;
    --secondary-color: #00bcd4;
    --text-color: #f2f2f2;
    --text-muted-color: #9e9e9e;
}

/* Pink Theme */
:root.theme-pink {
    --bg-color: #1f1d2b;
    --surface-color: #262837;
    --primary-color: #ff79c6;
    --secondary-color: #50fa7b;
    --text-color: #f8f8f2;
    --text-muted-color: #6272a4;
}

/* Light Theme */
:root.theme-light {
    --bg-color: #f8f9fa;
    --surface-color: #ffffff;
    --primary-color: #6200ee;
    --secondary-color: #018786;
    --text-color: #212529;
    --text-muted-color: #6c757d;
}

/* --- Core Styles --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
    font-size: 16px;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}
.header-title { 
    font-size: 1.5rem; 
    font-weight: 700; 
}
.header-menu a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid var(--text-muted-color);
    border-radius: 20px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.header-menu a:hover {
    background-color: var(--primary-color);
    color: var(--bg-color);
    border-color: var(--primary-color);
}

/* --- Main Content --- */
.main-content { 
    padding-top: 2.5rem; 
}

/* --- Input Forms --- */
#url-form, #stats-url-form { 
    display: flex; 
    gap: 1rem; 
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-grow: 1;
}

#url-input, #short-url-input {
    flex-grow: 1;
    width: 100%;
    font-size: 1rem;
    padding: 1rem 3.5rem 1rem 1.25rem;
    background-color: var(--surface-color);
    border: 1px solid transparent;
    border-radius: 50px;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s;
}
.theme-light #url-input, .theme-light #short-url-input {
    border: 1px solid #dee2e6;
}

#url-input:focus, #short-url-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

.paste-button {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    height: 80%;
    aspect-ratio: 1 / 1;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted-color);
    transition: background-color 0.2s, color 0.2s;
}
.paste-button:hover {
    background-color: color-mix(in srgb, var(--text-color) 10%, transparent);
    color: var(--text-color);
}
.paste-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}
.paste-button svg {
    width: 20px;
    height: 20px;
}

#generate-btn, #get-stats-btn {
    font-size: 1rem;
    font-weight: 500;
    padding: 1rem 1.5rem;
    background-color: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}
#generate-btn:hover, #get-stats-btn:hover { 
    transform: scale(1.05); 
}
#generate-btn:disabled, #get-stats-btn:disabled { 
    background-color: var(--text-muted-color); 
    cursor: not-allowed;
    transform: scale(1);
    opacity: 0.7;
}

/* --- Result Section --- */
#result-container {
    margin-top: 3rem;
    padding: 2rem;
    background-color: var(--surface-color);
    border-radius: 16px;
    display: none;
    flex-direction: column;
    gap: 2rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out, background-color 0.3s;
}
#result-container.visible { 
    display: flex; 
    opacity: 1;
    transform: translateY(0);
}
.theme-light #result-container {
    box-shadow: 0 4px 25px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.qr-column { 
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#qr-code-img-wrapper {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 12px;
    display: inline-block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
#qr-code-img {
    max-width: 256px;
    width: 100%;
    height: auto;
    display: block;
}
#download-btn {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.75rem 2rem;
    background-color: var(--secondary-color);
    color: var(--bg-color);
    text-decoration: none;
    font-weight: 500;
    border-radius: 50px;
    transition: transform 0.2s;
}
#download-btn:hover { 
    transform: scale(1.05); 
}

.stats-column {
    display: flex;
    flex-direction: column;
}
.stats-label { 
    color: var(--text-muted-color); 
    font-size: 0.9rem; 
    margin-bottom: 0.25rem;
}
#short-url-display {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--secondary-color);
    word-break: break-all;
    margin-bottom: 1.5rem;
}
.live-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #f00;
    border-radius: 50%;
    margin-right: 0.5rem;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}
#stats-display { 
    font-size: 2.5rem; 
    font-weight: 700; 
}

/* --- Campaign Section --- */
.campaign-section {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}
.text-button {
    background: none;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 500;
}
.text-button:hover {
    text-decoration: underline;
}
#campaign-input-container, #campaign-pill-container {
    margin-top: 0.5rem;
}
.pill {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--bg-color);
    padding: 0.4rem 0.9rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}
.pill:hover {
    opacity: 0.85;
}

/* --- Utility --- */
.error-message {
    color: #ff8a80;
    margin-top: 1rem;
    text-align: center;
    display: none;
}

/* --- Responsive Layout --- */
@media (max-width: 767px) {
    #url-form, #stats-url-form {
        flex-direction: column;
        gap: 0.75rem;
    }
    .input-wrapper, #generate-btn, #get-stats-btn {
        width: 100%;
    }
    
    #result-container {
        flex-direction: column;
    }
    .stats-column { order: 1; }
    .qr-column { order: 2; margin-top: 1.5rem; }
}

@media (min-width: 768px) {
    #result-container {
        flex-direction: row;
        align-items: center;
        gap: 3rem;
    }
    .qr-column { flex: 0 0 300px; }
    .stats-column { flex: 1; }
}