/* --- Global Variables & Resets (Reverted to Original Dark Theme) --- */
:root {
    --primary-color: #4CAF50; /* Green - Used for active elements, buttons */
    --primary-dark: #388E3C; /* Darker Green */
    --accent-color: #FFC107; /* Amber - Used for highlights, warnings */
    --text-color: #E0E0E0; /* Light grey for general text */
    --background-dark: #121212; /* Very dark background */
    --surface-dark: #1F1F1F; /* Slightly lighter surface for cards/panels */
    --border-color: #333333; /* Darker border */
    --shadow-color: rgba(0, 0, 0, 0.5); /* Stronger shadows */
    --input-bg: #2C2C2C; /* Darker background for input fields */
    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Open Sans', sans-serif;
    --spacing-unit: 1rem; /* 16px */
}

/* Import Google Fonts - **IMPORTANT: Add new Google Fonts here as you include them in app.js** */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Open+Sans:wght@400;600&family=Permanent+Marker&family=Kalam:wght@400;700&family=Indie+Flower&family=Dancing+Script:wght@400;700&family=Shadows+Into+Light&family=Caveat:wght@400;700&family=Handlee&family=Neucha&display=swap');

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--background-dark);
    padding: 20px;
    position: relative;
}

/* --- Particles.js Background --- */
#particles-js {
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: var(--background-dark);
    background-image: linear-gradient(135deg, #181818, #0a0a0a);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: 50% 50%;
    z-index: -1;
    opacity: 1;
}

/* --- App Header (Main Title Section) --- */
.app-header {
    background: var(--surface-dark);
    padding: calc(var(--spacing-unit) * 2.5);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    color: var(--text-color);
    border-radius: 12px;
    margin-bottom: calc(var(--spacing-unit) * 6);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 3em;
    color: var(--primary-color);
    margin-bottom: 0.2em;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.4);
    letter-spacing: 0.5px;
    font-weight: 700;
}

.app-header p {
    font-size: 1.1em;
    color: var(--text-color);
    opacity: 0.9;
}

/* --- Main Content Layout (Vertical Stacking) --- */
.app-main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0;
}

/* --- Panels (Dark Cards) --- */
.panel {
    background: var(--surface-dark);
    padding: calc(var(--spacing-unit) * 2.5);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin-bottom: calc(var(--spacing-unit) * 6);
}

.panel:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.6);
    background: #282828;
}

.panel h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 2em;
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    text-align: center;
    padding-bottom: 1em;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
}

/* --- Input Section --- */
#assignmentText {
    min-height: 350px;
    resize: vertical;
    border-color: var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-color);
    padding: 1rem;
    border-radius: 8px;
    font-size: 1em;
}

.clear-btn {
    background-color: #F44336;
    color: var(--text-color);
    border: none;
    padding: 1rem 1.8rem;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    margin-top: calc(var(--spacing-unit) * 1.5);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.4);
}

.clear-btn:hover:not(:disabled) {
    background-color: #D32F2F;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(244, 67, 54, 0.5);
}

.clear-btn:disabled {
    background-color: #555555;
    color: #909090;
    cursor: not-allowed;
    box-shadow: none;
}

/* --- Character/Word Count Display --- */
.word-count-display {
    text-align: right;
    font-size: 0.9em;
    color: #B0B0B0;
    margin-top: 0.5rem;
    padding-right: 0.5rem;
}

/* --- Options Section --- */
.option-group {
    margin-bottom: calc(var(--spacing-unit) * 1.5);
}

.option-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: var(--text-color);
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.input-field,
.select-field {
    width: 100%;
    padding: 0.9rem 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: var(--font-body);
    color: var(--text-color);
    background-color: var(--input-bg);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    outline: none;
}

.input-field::placeholder {
    color: #A0A0A0;
}

.input-field:focus,
.select-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.3);
    background-color: #3C3C3C;
}

.select-field {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23E0E0E0%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13.2-6.4H18.6c-5%200-9.3%201.8-13.2%205.4A17.6%2017.6%200%200%200%200%2075.8c0%205.4%201.8%209.7%205.4%2013.2l128%20127.9c3.6%203.6%207.8%205.4%2013.2%205.4s9.6-1.8%2013.2-5.4l128-127.9c3.6-3.5%205.4-7.8%205.4-13.2%200-5.3-1.8-9.6-5.4-13.1z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
    cursor: pointer;
    padding-right: 35px;
}

.color-picker {
    padding: 0.2rem;
    height: 45px;
    cursor: pointer;
    width: 60px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: transparent;
    vertical-align: middle;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.color-picker::-moz-color-swatch {
    border: none;
    border-radius: 6px;
}

.slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 12px;
    background: var(--input-bg);
    outline: none;
    border-radius: 6px;
    transition: background 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: grab;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    transition: background-color 0.2s ease, transform 0.2s ease;
    border: 3px solid var(--surface-dark);
}

.slider::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.15);
}
.slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: grab;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    transition: background-color 0.2s ease, transform 0.2s ease;
    border: 3px solid var(--surface-dark);
}
.slider::-moz-range-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.15);
}

.hint {
    font-size: 0.9em;
    color: #B0B0B0;
    margin-top: 0.6rem;
    font-style: italic;
    opacity: 0.8;
}

/* --- Preview & Generate Section --- */
.preview-generate-section {
    text-align: center;
    padding-top: var(--spacing-unit);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: calc(var(--spacing-unit) * 6);
}

.live-preview-container {
    width: 100%;
    max-width: 900px;
    min-height: 400px;
    margin: calc(var(--spacing-unit) * 2) auto;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
    background-color: #fff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#assignmentCanvas {
    background-color: #fff;
    display: block;
    max-width: 100%;
    height: auto;
}

.preview-placeholder-text {
    position: absolute;
    color: #888;
    font-style: italic;
    font-size: 1.4em;
    text-align: center;
    padding: 20px;
    user-select: none;
    pointer-events: none;
}
/* Hide placeholder when canvas has actual content (width/height attributes) */
.live-preview-container:has(#assignmentCanvas[width][height]) .preview-placeholder-text {
    display: none;
}

#pageNav {
    margin-top: 14px;
    font-size: 1.15em;
}
#pageNav .page-btn {
    display: inline-block;
    background: #222;
    color: #eee;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    margin: 0 2px;
    padding: 0.3em 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
#pageNav .page-btn:hover,
#pageNav .page-btn[style*="background:#00ffe7"] {
    background: var(--primary-color);
    color: #111;
}

/* --- Generate Button --- */
.generate-btn {
    width: 100%;
    max-width: 500px;
    padding: 1.4rem 2.2rem;
    background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
    color: var(--text-color);
    border: none;
    border-radius: 10px;
    font-size: 1.6em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    margin-top: calc(var(--spacing-unit) * 2);
}

.generate-btn:hover:not(:disabled) {
    background: linear-gradient(45deg, var(--primary-dark), #2E7D32);
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
}

.generate-btn:disabled {
    background: #555555;
    color: #909090;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.status-message {
    margin-top: calc(var(--spacing-unit) * 2);
    font-size: 1.2em;
    color: var(--text-color);
    min-height: 1.5em;
    font-weight: 600;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}
.status-message.error {
    color: #FF5252;
}
.status-message.success {
    color: var(--accent-color);
}
.status-message.warning {
    color: #FFEA00;
}

.progress-bar-container {
    width: 100%;
    max-width: 500px;
    height: 12px;
    background-color: #333333;
    border-radius: 6px;
    margin-top: 1.5rem;
    overflow: hidden;
    display: none;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.3);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 6px;
    transition: width 0.1s ease-in-out;
}

/* --- Footer (inside content-wrapper) --- */
.app-footer {
    background: var(--surface-dark);
    padding: calc(var(--spacing-unit) * 1.5);
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: calc(var(--spacing-unit) * 2);
    color: #B0B0B0;
    opacity: 0.9;
    font-size: 0.95em;
    border-radius: 12px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.app-footer p {
    font-size: 1em;
}

/* --- NEW: Flexible Spacer / Ad Placeholder --- */
.flexible-spacer {
    width: 100%;
    max-width: 900px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(76, 175, 80, 0.4);
    border-radius: 12px;
    color: rgba(76, 175, 80, 0.6);
    font-family: var(--font-heading);
    font-size: 1.8em;
    font-weight: 600;
    text-align: center;
    margin: calc(var(--spacing-unit) * 6) auto;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    padding: 20px;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.flexible-spacer:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);
    transform: scale(1.01);
}

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

.panel, .app-header, .app-footer, .flexible-spacer {
    animation: fadeInUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
}

.app-header { animation-delay: 0.1s; }
.input-section { animation-delay: 0.2s; }
.flexible-spacer:nth-of-type(1) { animation-delay: 0.3s; }
.options-section { animation-delay: 0.4s; }
.flexible-spacer:nth-of-type(2) { animation-delay: 0.5s; }
.preview-generate-section { animation-delay: 0.6s; }
.app-footer { animation-delay: 0.8s; }


/* Confetti (colors can be adjusted if needed for new theme) */
@keyframes fall {
    0% { transform: translateY(-100px) rotateZ(0deg) scale(0); opacity: 0; }
    50% { opacity: 1; transform: translateY(50vh) rotateZ(360deg) scale(1); }
    100% { transform: translateY(100vh) rotateZ(720deg) scale(0.5); opacity: 0; }
}
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}
.confetti-piece {
    position: absolute;
    width: 15px;
    height: 15px;
    animation: fall 5s cubic-bezier(0.4, 0, 1, 1) forwards;
    opacity: 0;
    border-radius: 50%;
}

/* --- Responsive Design --- */
@media (max-width: 1024px) {
    body {
        padding: 15px;
    }
    .app-header, .panel, .app-footer, .flexible-spacer {
        max-width: 100%;
        border-radius: 8px;
    }
    .app-header {
        padding: calc(var(--spacing-unit) * 2);
        margin-bottom: calc(var(--spacing-unit) * 3);
    }
    .app-header h1 {
        font-size: 2.5em;
    }
    .app-header p {
        font-size: 1em;
    }
    .panel {
        padding: calc(var(--spacing-unit) * 2);
        margin-bottom: calc(var(--spacing-unit) * 3);
    }
    .panel h2 {
        font-size: 1.8em;
    }
    .live-preview-container {
        height: 400px;
        margin: var(--spacing-unit) auto;
    }
    .generate-btn {
        max-width: 400px;
        font-size: 1.3em;
        padding: 1rem 1.8rem;
    }
    .flexible-spacer {
        min-height: 120px;
        font-size: 1.4em;
        margin: calc(var(--spacing-unit) * 3) auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .app-header {
        padding: calc(var(--spacing-unit) * 1.5);
        margin-bottom: calc(var(--spacing-unit) * 2.5);
    }
    .app-header h1 {
        font-size: 2em;
    }
    .app-header p {
        font-size: 1em;
    }
    .panel {
        padding: calc(var(--spacing-unit) * 1.5);
        margin-bottom: calc(var(--spacing-unit) * 2.5);
    }
    .panel h2 {
        font-size: 1.5em;
    }
    .clear-btn, .generate-btn {
        font-size: 1em;
        padding: 0.8rem 1.2rem;
    }
    .input-field, .select-field {
        padding: 0.8rem 1rem;
        font-size: 0.95em;
    }
    .live-preview-container {
        height: 350px;
    }
    .preview-placeholder-text {
        font-size: 1.1em;
    }
    .status-message {
        font-size: 1em;
    }
    .flexible-spacer {
        min-height: 100px;
        font-size: 1.2em;
        margin: calc(var(--spacing-unit) * 2.5) auto;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    .app-header {
        padding: var(--spacing-unit);
        margin-bottom: calc(var(--spacing-unit) * 2);
    }
    .app-header h1 {
        font-size: 1.6em;
    }
    .app-header p {
        font-size: 0.85em;
    }
    .panel {
        padding: var(--spacing-unit);
        margin-bottom: calc(var(--spacing-unit) * 2);
    }
    .panel h2 {
        font-size: 1.3em;
    }
    .live-preview-container {
        height: 250px;
    }
    .generate-btn {
        font-size: 0.9em;
        padding: 0.7rem 1rem;
    }
    .option-group label {
        font-size: 1em;
    }
    .hint {
        font-size: 0.8em;
    }
    .flexible-spacer {
        min-height: 80px;
        font-size: 1em;
        margin: calc(var(--spacing-unit) * 2) auto;
    }
}