/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', sans-serif;
    /* Enforce font globally */
}

body {
    background-color: #f2f7ff;
    /* Dark Blue Theme */
    color: #333;
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    background: #fff;
    width: 100%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: #0a2d68;
    color: #fff;
    padding: 30px 20px;
    text-align: center;
    border-bottom: 4px solid #062a66;
    position: relative;
    /* For absolute positioning of reset btn */
}

header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

header p {
    font-size: 14px;
    color: #cfe1ff;
}

/* ... */

.btn-reset {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.3);
}

main {
    padding: 30px;
}

/* Form Styles */
.form-group {
    margin-bottom: 24px;
    /* Increased spacing */
}

.form-row {
    display: flex;
    gap: 20px;
    /* Increased gap */
    margin-bottom: 24px;
}

.form-group.half {
    flex: 1;
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 10px;
    /* Increased label spacing */
    font-weight: 600;
    color: #0b3d91;
    font-size: 15px;
    /* Slightly larger label */
}

input[type="text"],
input[type="url"],
/* Added url type */
select {
    width: 100%;
    padding: 14px 16px;
    /* More padding */
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    /* More rounded */
    font-family: 'Sarabun', sans-serif;
    font-size: 16px;
    /* Larger font for better readability */
    transition: all 0.3s ease;
    background-color: #f9faff;
    /* Subtle background */
    color: #333;
}

/* Custom Dropdown Arrow */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230b3d91' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
    /* Space for arrow */
    cursor: pointer;
}

input[type="text"]:focus,
input[type="url"]:focus,
select:focus {
    border-color: #0b3d91;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(11, 61, 145, 0.1);
    /* Focus ring */
    outline: none;
}

input::placeholder {
    color: #a0aec0;
}

/* File Upload Styling */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

input[type="file"] {
    font-size: 14px;
    width: 100%;
    padding: 10px;
    background: #f4f6fb;
    border: 1px dashed #0b3d91;
    border-radius: 6px;
    cursor: pointer;
}

/* Buttons */
.btn-generate {
    width: 100%;
    padding: 18px;
    background: #0b3d91;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.btn-generate:hover {
    background: #082d6e;
}

.btn-generate:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}



/* Output Section */
.output-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.output-header h2 {
    font-size: 18px;
    color: #0b3d91;
    margin: 0;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-copy,
.btn-secondary {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy {
    background: #f0f4ff;
    color: #0b3d91;
    border: 1px solid #dbe9ff;
}

.btn-secondary {
    background: #fff;
    color: #0b3d91;
    border: 1px solid #0b3d91;
}

.btn-copy:hover,
.btn-secondary:hover {
    background: #dbe9ff;
    border-color: #b3c7e6;
}

textarea {
    width: 100%;
    height: 150px;
    padding: 10px;
    border: 1px solid #0b3d91;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
    background: #fafafa;
    color: #0b3d91;
}

.hint {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
    text-align: center;
}

/* Preview Section */
.preview-container {
    margin-bottom: 30px;
    /* Space between preview and code */
    /* Removed top border and margin as it's now first */
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-container h3 {
    font-size: 18px;
    /* Matched to h2 */
    color: #0b3d91;
    margin: 0;
}

#previewFrame {
    width: 100%;
    height: 500px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

/* Responsive */
@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
        gap: 20px;
    }
}