/* ============================================================================
   POJ Handwriting Practice Generator - Styles
   ============================================================================ */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
    --primary-color: #ff9a9e;
    --primary-hover: #ff8085;
    --secondary-color: #a18cd1;
    --accent-color: #fad0c4;
    --bg-color: #fff5f5;
    --text-color: #6c5ce7;
    --border-color: #ffdde1;
    --card-bg: #ffffff;
    --button-gradient: linear-gradient(120deg, #a18cd1 0%, #fbc2eb 100%);
}

/* ============================================================================
   RESET & BASE STYLES
   ============================================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'OpenHuninn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */
@font-face {
    font-family: 'Iansui';
    src: url('../assets/fonts/Iansui-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'OpenHuninn';
    src: url('../assets/fonts/jf-openhuninn.ttf') format('truetype');
}

h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* ============================================================================
   LAYOUT & CONTAINER
   ============================================================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.layout-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.controls-column {
    flex: 4;
}

.preview-column {
    flex: 3;
    position: sticky;
    top: 2rem;
}

@media (max-width: 900px) {
    .layout-container {
        flex-direction: column;
    }

    .controls-column,
    .preview-column {
        width: 100%;
        flex: none;
    }

    .preview-column {
        position: static;
    }
}

/* ============================================================================
   HEADER & NAVIGATION
   ============================================================================ */
header {
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.header-text {
    flex: 1;
}


.language-group {
    display: flex;
    background: white;
    padding: 0.3rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    gap: 0.2rem;
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    color: #95a5a6;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    min-width: unset;
    height: auto;
    font-family: 'OpenHuninn', sans-serif;
}

.lang-btn:hover {
    color: var(--secondary-color);
    background: rgba(255, 154, 158, 0.1);
}

.lang-btn.active {
    background: var(--button-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(161, 140, 209, 0.3);
}

@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .language-group {
        width: auto;
    }
}

/* ============================================================================
   FORMS & INPUTS
   ============================================================================ */
input,
select,
textarea,
button {
    font-family: 'OpenHuninn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

select,
input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1.5;
    min-height: 3.5rem;
}

textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'OpenHuninn', 'Noto Serif', serif;
    font-size: 1rem;
    resize: vertical;
    min-height: 150px;
    line-height: 1.5;
}

label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 0.8rem;
}

.input-with-clear {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-with-clear input,
.input-with-clear textarea {
    flex: 1;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.primary-btn {
    background-image: var(--button-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(161, 140, 209, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(161, 140, 209, 0.6);
}

.secondary-btn {
    background: white;
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.secondary-btn:hover {
    background: rgba(161, 140, 209, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(161, 140, 209, 0.2);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.button-group button {
    flex: 1;
}

.clear-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 60px;
}

.clear-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(255, 154, 158, 0.3);
}

/* ============================================================================
   SETTINGS SECTIONS
   ============================================================================ */
.controls {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(255, 154, 158, 0.15);
    margin-bottom: 0;
    border: 1px solid var(--border-color);
}

.settings-section {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
}

.settings-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0.5rem;
}

.settings-section h3 {
    grid-column: 1 / -1;
    color: var(--secondary-color);
    margin-bottom: 0.3rem;
    font-size: 1.1rem;
}

.settings-section:has(.text-settings-grid) {
    display: block;
    width: 100%;
}

.text-settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    width: 100%;
}

.text-settings-grid .form-group {
    margin-bottom: 0;
    margin-top: 0.7rem;
}

.text-settings-grid input,
.text-settings-grid textarea {
    width: 100%;
    box-sizing: border-box;
}

/* ============================================================================
   PREVIEW SECTION
   ============================================================================ */
.preview-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(255, 154, 158, 0.15);
    border: 1px solid var(--border-color);
}

#previewContainer {
    border: 1px solid var(--border-color);
    min-height: 300px;
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
}

.placeholder {
    color: #95a5a6;
    font-style: italic;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
footer {
    text-align: center;
    margin-top: 2rem;
    color: #7f8c8d;
}

.footer-btn {
    display: inline-block;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer-btn:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* ============================================================================
   TAB NAVIGATION
   ============================================================================ */
.tab-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(255, 154, 158, 0.1);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(255, 154, 158, 0.05);
}

/* ============================================================================
   TAB CONTENT
   ============================================================================ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

#premade-section {
    width: 100%;
    flex: 1;
}

.generator-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

/* ============================================================================
   PREMADE SECTION
   ============================================================================ */
.premade-container {
    width: 100%;
    padding: 0 2rem;
    text-align: center;
}

.premade-container h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.premade-intro {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.premade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    justify-items: center;
}

.premade-card {
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(255, 154, 158, 0.15);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
}

.premade-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(255, 154, 158, 0.25);
}

.card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.card-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-content h3 {
    color: var(--secondary-color);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.card-content p {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.premade-btn {
    background-image: var(--button-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(161, 140, 209, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.premade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(161, 140, 209, 0.6);
}

.premade-btn .icon {
    font-size: 1.2rem;
}

/* Tag Filter Bar */
.tag-filter-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 154, 158, 0.05);
    border-radius: 16px;
}

.tag-btn {
    background: white;
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tag-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 154, 158, 0.3);
}

.tag-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(255, 154, 158, 0.3);
}

/* Card Hashtags */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.hashtag {
    background: rgba(161, 140, 209, 0.1);
    color: var(--secondary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Card Date */
.card-date {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: auto;
}

.card-date::before {
    content: '📅';
    font-size: 1rem;
    filter: grayscale(100%) opacity(0.6);
}

/* Hide cards by default when filtering */
.premade-card.hidden {
    display: none;
}

/* Responsive adjustments for tabs */
@media (max-width: 900px) {
    .generator-layout {
        flex-direction: column;
    }

    .controls-column,
    .preview-column {
        width: 100%;
        flex: none;
    }

    .preview-column {
        position: static;
    }

    .premade-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 600px) {
    .tab-nav {
        gap: 0.5rem;
    }

    .tab-btn {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }

    .premade-grid {
        grid-template-columns: 1fr;
    }
}