:root {
    --primary-color: #003366;
    /* BC Gov Blue-ish */
    --primary-hover: #004080;
    --accent-color: #eeb111;
    /* BC Gold-ish */
    --bg-gradient-start: #f0f4f8;
    --bg-gradient-end: #d9e2ec;
    --text-main: #102a43;
    --text-muted: #486581;
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-md: 12px;
    --radius-lg: 20px;
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    z-index: -1;
}

/* Decorative background shapes */
.background-gradient::before,
.background-gradient::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.6;
}

.background-gradient::before {
    width: 400px;
    height: 400px;
    background: rgba(0, 51, 102, 0.15);
    top: -100px;
    left: -100px;
}

.background-gradient::after {
    width: 300px;
    height: 300px;
    background: rgba(238, 177, 17, 0.15);
    bottom: -50px;
    right: -50px;
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-top: 2rem;
}

.hero {
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInDown 0.8s ease-out;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Search Section */
.search-section {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    text-align: center;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.input-group {
    display: flex;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #cbd5e0;
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font-family);
    text-transform: uppercase;
}

input[type="text"]:focus {
    border-color: var(--primary-color);
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.primary-btn:active {
    transform: scale(0.98);
}

.error-msg {
    color: #e53e3e;
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.mla-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
}

.mla-header {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.mla-photo-container {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid white;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.mla-photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mla-info h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.district {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.party {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.email-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

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

/* Action Center */
.action-center {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
}

.action-center h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.action-center>p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.topic-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.topic-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

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

.topic-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Letter Preview */
.letter-preview {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.preview-header h4 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.secondary-btn {
    background: white;
    border: 1px solid #cbd5e0;
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

textarea {
    width: 100%;
    height: 300px;
    padding: 1rem;
    border: 1px solid #cbd5e0;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    background: white;
    color: var(--text-main);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Utilities */
.hidden {
    display: none !important;
}

.loader {
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .input-group {
        flex-direction: column;
    }

    .mla-header {
        flex-direction: column;
        text-align: center;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-actions {
        width: 100%;
    }

    .preview-actions button {
        flex: 1;
        justify-content: center;
    }
}

/* Manual Selection */
.manual-selection {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    text-align: center;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.manual-selection h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.manual-selection p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.select-wrapper {
    position: relative;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

.select-wrapper::after {
    content: '▼';
    font-size: 0.8rem;
    color: var(--text-muted);
    position: absolute;
    right: 16px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

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

.topic-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Letter Preview */
.letter-preview {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.preview-header h4 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.secondary-btn {
    background: white;
    border: 1px solid #cbd5e0;
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

textarea {
    width: 100%;
    height: 300px;
    padding: 1rem;
    border: 1px solid #cbd5e0;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    background: white;
    color: var(--text-main);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Utilities */
.hidden {
    display: none !important;
}

.loader {
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .input-group {
        flex-direction: column;
    }

    .mla-header {
        flex-direction: column;
        text-align: center;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-actions {
        width: 100%;
    }

    .preview-actions button {
        flex: 1;
        justify-content: center;
    }
}

/* Manual Selection */
.manual-selection {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    text-align: center;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.manual-selection h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.manual-selection p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.select-wrapper {
    position: relative;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

.select-wrapper::after {
    content: '▼';
    font-size: 0.8rem;
    color: var(--text-muted);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #cbd5e0;
    border-radius: var(--radius-md);
    outline: none;
    appearance: none;
    background: white;
    font-family: var(--font-family);
    color: var(--text-main);
    cursor: pointer;
}

select:focus {
    border-color: var(--primary-color);
}

#manual-confirm-btn {
    margin: 0 auto;
}

/* Tone Selector */
.tone-selector-container {
    margin-bottom: 1.5rem;
}

.tone-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.tone-selector {
    display: inline-flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.tone-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tone-btn:hover {
    color: var(--text-main);
}

.tone-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}