:root {
    --primary-color: #008779; /* Màu xanh lá cây cho nút Download */
    --secondary-color: #004080; /* Màu xanh đậm cho Frame và Title */
    --light-bg: #f5f7fa;
    --border-color: #e0e0e0;
    --muted-text: #6c757d;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: var(--light-bg);
    padding: 20px;
}

/* --- Layout chính --- */
.main-container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.left-column {
    flex: 2; /* Chiếm khoảng 65-70% chiều rộng */
    padding: 30px;
    border-right: 1px solid var(--border-color);
}

.right-column {
    flex: 1; /* Chiếm khoảng 30-35% chiều rộng */
    padding: 30px;
}

/* --- Section Titles --- */
.section-title {
    font-size: 1.2em;
    color: var(--secondary-color);
    margin-bottom: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}

/* --- 1. Content Type Selector --- */
.content-type-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

.type-btn {
    flex-basis: calc(20% - 8px); /* 5 nút/hàng */
    padding: 10px 5px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--muted-text);
    text-align: center;
    transition: all 0.2s;
}

/* --- Style cho nút Tạo QR Code (nút phụ) --- */
.generate-button {
    background-color: #fff;
    color: var(--secondary-color);
    border: 2px solid var(--secondary-color);
    margin-bottom: 10px; /* Tạo khoảng cách với nút Download */
}

.generate-button:hover {
    background-color: var(--secondary-color);
    color: #fff;
}

.type-btn img {
    display: block;
    width: 20px;
    height: 20px;
    margin: 0 auto 5px;
}

.type-btn:hover,
.type-btn.active {
    background-color: var(--secondary-color);
    color: #fff;
    border-color: var(--secondary-color);
}

/* --- 1. Content Section --- */
.content-section label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

#dataInput {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: vertical;
}

.char-counter-wrap {
    text-align: right;
    font-size: 0.85em;
    color: var(--muted-text);
    margin-top: 5px;
}

/* --- 2. Design Tabs --- */
.design-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.design-tab {
    padding: 10px 15px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: bold;
    color: var(--muted-text);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.design-tab.active {
    color: var(--secondary-color);
    border-bottom: 3px solid var(--secondary-color);
}

/* --- Frame Selector --- */
.frame-selector-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 0;
    overflow-x: auto;
}

.frame-option {
    width: 60px;
    height: 60px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

/* Thêm rule này để đảm bảo cả SVG và Image đều fill đúng kích thước ô chọn */
.frame-option svg,
.frame-option img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block; /* Quan trọng cho SVG */
}

.frame-option.active {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(0, 64, 128, 0.2);
}

/* --- Frame Details --- */
.frame-details-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.frame-detail {
    flex: 1;
}

.frame-detail label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #333;
}

.frame-detail input[type="text"],
.frame-detail select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1em;
}

.color-input-wrap {
    display: flex;
    align-items: center;
}

.color-input-wrap label {
    flex-shrink: 0;
    margin-right: 10px;
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    margin-left: 10px;
    cursor: pointer;
}

/* Ẩn các tab content không hoạt động */
.design-content {
    display: none;
}
.design-content.active {
    display: block;
}

/* --- 3. QR Preview & Download --- */
.qr-preview-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* Hình vuông */
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

#qrImage {
    max-width: 100%;
    height: auto;
    /* Dùng filter để mô phỏng màu trắng của QR trong ảnh */
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.1)); 
}

#scanMeText {
    position: absolute;
    bottom: 20px;
    background-color: var(--secondary-color);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 1.1em;
    font-weight: bold;
    text-transform: uppercase;
}

.primary-btn {
    width: 100%;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #006f63;
}
/* --- Styles cho Validation và Lỗi --- */

.validation-error {
    color: #dc2626; /* Màu đỏ */
    font-size: 0.9em;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid #f87171;
    background-color: #fee2e2;
    border-radius: 4px;
}

/* Kiểu dáng cho input không hợp lệ */
.input-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 1px #dc2626;
}
/* --- Styles cho các nhóm trường đặc biệt (ví dụ: vCard) --- */

.vcard-group {
    margin-bottom: 15px;
}

.vcard-group > label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

/* Định dạng hai trường input trên cùng một dòng (First Name / Last Name) */
.vcard-group input[type="text"]:first-of-type {
    width: calc(50% - 5px);
    display: inline-block;
    margin-right: 10px;
}

.vcard-group input[type="text"]:last-of-type {
    width: calc(50% - 5px);
    display: inline-block;
}

/* Kiểu dáng chung cho các input phụ */
.content-section input[type="text"],
.content-section input[type="email"],
.content-section input[type="tel"],
.content-section input[type="url"],
.content-section input[type="password"],
.content-section select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 15px; /* Tạo khoảng cách giữa các trường */
    font-size: 1em;
}

.content-section textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: vertical;
    margin-bottom: 15px;
}

/* Loại bỏ margin bottom cho input cuối cùng trong nhóm */
.content-section div:last-child input:last-child,
.content-section div:last-child textarea:last-child {
    margin-bottom: 0;
}