/* CSS Custom Properties for Themes */
:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-container: #1a1a1a;
    --bg-main: #0a0a0a;
    --text-primary: #00ffcc;
    --text-secondary: #FFFFFF;
    --text-muted: #9CA3AF;
    --accent-color: #00ffcc;
    --border-color: #00ffcc;
    --shadow-color: #00ffcc;
    --input-bg: #1a1a1a;
    --button-primary-bg: #00ffcc;
    --button-primary-text: #0a0a0a;
    --button-secondary-bg: #0a0a0a;
    --button-secondary-text: #00ffcc;
    --card-bg: #1a1a1a;
    --card-hover-bg: #0a0a0a;
    --gradient-start: #7C3AED;
    --gradient-end: #00C4FF;
    --success-color: #10B981;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #dc2626;
}

[data-theme="light"] {
    /* Light theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-container: #ffffff;
    --bg-main: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent-color: #3b82f6;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --button-primary-bg: #3b82f6;
    --button-primary-text: #ffffff;
    --button-secondary-bg: #ffffff;
    --button-secondary-text: #3b82f6;
    --card-bg: #ffffff;
    --card-hover-bg: #f8fafc;
    --gradient-start: #3b82f6;
    --gradient-end: #06b6d4;
    --success-color: #059669;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #dc2626;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-container);
    border: 2px solid var(--border-color);
    box-shadow: 0 0 20px var(--shadow-color);
    border-radius: 8px;
    margin-top: 2rem;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--text-primary);
    position: relative;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 2rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.brand-tagline {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.brand-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.brand-link:hover {
    color: var(--text-primary);
}

.theme-toggle {
    background: var(--button-secondary-bg);
    border: 2px solid var(--border-color);
    color: var(--button-secondary-text);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--accent-color);
    color: var(--button-primary-text);
    transform: scale(1.05);
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.draft-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    transition: all 0.3s ease;
}

.draft-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 255, 204, 0.1);
}

.char-count {
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.scan-btn {
    background: var(--button-primary-bg);
    color: var(--button-primary-text);
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    align-self: center;
    min-width: 200px;
}

.scan-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 204, 0.3);
}

.scan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.2rem;
}

/* Turnstile Widget Centering */
.cf-turnstile {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 1rem 0 !important;
    width: 100% !important;
}

/* Ensure Turnstile widget itself is centered */
.cf-turnstile > div {
    margin: 0 auto !important;
}

/* Responsive centering for mobile */
@media (max-width: 640px) {
    .cf-turnstile {
        padding: 0 1rem !important;
    }
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.hidden {
    display: none !important;
}

/* Tone Analysis */
.tone-analysis {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-align: center;
}

.tone-chart {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tone-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tone-bar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tone-label {
    min-width: 100px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tone-bar-container {
    flex: 1;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.tone-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease;
    position: relative;
}

.tone-bar-fill.serious { background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.tone-bar-fill.inspiring { background: linear-gradient(90deg, #f59e0b, #d97706); }
.tone-bar-fill.playful { background: linear-gradient(90deg, #10b981, #059669); }
.tone-bar-fill.bold { background: linear-gradient(90deg, #ef4444, #dc2626); }
.tone-bar-fill.casual { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }
.tone-bar-fill.humorous { background: linear-gradient(90deg, #f97316, #ea580c); }

.tone-percentage {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
}

.tone-reason {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
}

/* Emoji Feedback */
.emoji-feedback {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.feedback-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.emoji-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.emoji-btn {
    background: var(--button-secondary-bg);
    border: 2px solid var(--border-color);
    color: var(--button-secondary-text);
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
}

.emoji-btn:hover {
    background: var(--accent-color);
    color: var(--button-primary-text);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 204, 0.2);
}

.emoji-btn.selected {
    background: var(--accent-color);
    color: var(--button-primary-text);
    border-color: var(--accent-color);
}

.emoji {
    font-size: 2rem;
}

.vibe-name {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Rewrite Section */
.rewrite-section {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.rewrite-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rewritten-text {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    min-height: 100px;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.copy-btn {
    background: var(--button-primary-bg);
    color: var(--button-primary-text);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    align-self: flex-start;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 204, 0.3);
}

/* Loading Section */
.loading-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Error Section */
.error-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.error-content {
    text-align: center;
    background: var(--error-bg);
    border: 2px solid var(--error-border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-message {
    color: var(--error-text);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.retry-btn {
    background: var(--button-primary-bg);
    color: var(--button-primary-text);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 204, 0.3);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.generate-btn {
    background: var(--button-primary-bg);
    color: var(--button-primary-text);
    border: 2px solid var(--accent-color);
    padding: 1rem 2rem;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
    font-family: 'Courier New', monospace;
}

.generate-btn:hover:not(:disabled) {
    background: var(--button-secondary-bg);
    color: var(--button-secondary-text);
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--shadow-color);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.topic-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: vertical;
    min-height: 120px;
}

.topic-input::placeholder {
    color: var(--text-primary);
    opacity: 0.6;
}

.topic-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: var(--input-bg);
    box-shadow: 0 0 10px var(--shadow-color);
}

/* Turnstile */
.turnstile-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.cf-turnstile {
    transform: scale(0.9);
}

/* Output Section */
.output-section {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.output-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: center;
}

.hooks-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Footer */
.footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
    text-align: center;
}

.powered-by {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.powered-by strong {
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.footer-link {
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-link:hover {
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--shadow-color);
}

.return-link {
    margin-top: 0.5rem;
}

.return-link-text {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.return-link-text:hover {
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--shadow-color);
    transform: translateX(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 1rem;
        padding: 1.5rem 1rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .emoji-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-top {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.75rem;
    }
    
    .emoji-buttons {
        grid-template-columns: 1fr;
    }
    
    .scan-btn {
        width: 100%;
    }
}
