/* Color Variables for Theming */
:root {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9fafb;
    --text-primary: #1f2937;
    --text-secondary: #374151;
    --text-muted: #4b5563;
    --border-color: #e5e7eb;
    --input-border: #d1d5db;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --red-500: #ef4444;
    --red-700: #b91c1c;
    --white: #ffffff;
    --black: #000000;
}

body.dark-mode {
    --bg-primary: #111827;      /* gray-900 */
    --bg-secondary: #1f2937;     /* gray-800 */
    --bg-tertiary: #374151;      /* gray-700 */
    --text-primary: #f9fafb;     /* gray-50 */
    --text-secondary: #d1d5db;   /* gray-300 */
    --text-muted: #9ca3af;       /* gray-400 */
    --border-color: #374151;     /* gray-700 */
    --input-border: #4b5563;     /* gray-600 */
    --shadow-color: rgba(0, 0, 0, 0.4);
}

/* General Styling */
body {
    margin: 0;
    font-family: sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout Containers */
.main-container {
    max-width: 80rem;
    margin: 0 auto;
}

.card {
    background-color: var(--bg-secondary);
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -2px var(--shadow-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    transition: background-color 0.3s;
}

/* Header & Logo Styles */
.header-main {
    position: relative;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.logo-box {
    background-color: var(--black);
    color: var(--white);
    font-weight: bold;
    font-size: 1.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    line-height: 1;
}

.logo-title {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.theme-toggle-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 9999px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle-btn .icon-moon { display: none; }
.theme-toggle-btn .icon-sun { display: block; }
body.dark-mode .theme-toggle-btn .icon-moon { display: block; }
body.dark-mode .theme-toggle-btn .icon-sun { display: none; }


/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-title i {
    color: var(--blue-500);
}

/* Form Elements */
.input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    box-sizing: border-box;
    font-size: 1rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
.input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}
textarea.input {
    min-height: 80px;
    resize: vertical;
}
.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}
.btn-primary {
    background-color: var(--blue-500);
    color: var(--white);
}
.btn-primary:hover {
    background-color: var(--blue-600);
}
.btn:disabled {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Character & Dialogue Cards */
.item-card {
    position: relative;
    background-color: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s, border-color 0.3s;
}
.item-card-title {
    font-size: 1.125rem;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 1.25rem;
}
.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--red-500);
    cursor: pointer;
    padding: 0.25rem;
}
.remove-btn:hover {
    color: var(--red-700);
}

/* Output Section */
.output-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.output-card {
    background-color: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}
.output-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 1rem;
}
.output-textarea {
    width: 100%;
    height: 12rem;
    background-color: var(--bg-secondary);
    font-family: monospace;
    resize: none;
    margin-bottom: 0.75rem;
}
.btn-copy {
    background-color: var(--green-500);
    color: white;
}
.btn-copy:hover {
    background-color: var(--green-600);
}

/* Grid Layouts & Responsive Design */
.grid-container {
    display: grid;
    gap: 1.25rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(1, 1fr);
}
.col-span-2 {
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
    /* === BAHAGIAN YANG DIBETULKAN === */
    /* Kod ini memastikan grid 2-kolum untuk Langkah 3 berfungsi pada saiz skrin yang betul */
    .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    /* === TAMAT BAHAGIAN YANG DIBETULKAN === */
    
     .item-card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .col-span-full {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1024px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
    .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Footer Styles */
.site-footer {
    text-align: center;
    padding: 1rem;
    margin-top: 2.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}