/* ====================================================
   1️⃣  BASE CONTAINER & VARIABLES
   ==================================================== */
:root {
    --qf-bg-dark: #1a1a2e;
    --qf-bg-card: #252a40;
    --qf-primary: #0d6efd;
    --qf-secondary: #6c757d;
    --qf-success: #28a745;
    --qf-warning: #ffc107;
    --qf-danger: #dc3545;
    --qf-text-light: #f8f9fa;
    --qf-text-muted: #adb5bd;
    --qf-border: #495057;
}

.quote-form-container {
    max-width: 1200px;
    margin: 40px auto;
    font-family: 'Sarabun', sans-serif;
    color: var(--qf-text-light);
}

@media (max-width: 768px) {
    .quote-form-container {
        padding: 0 15px;
        margin: 20px auto;
    }
}

/* Theme Classes */
.qf-theme-orange .quote-form-card {
    border-color: #f39c12;
}

.qf-theme-orange .quote-form-header {
    background: linear-gradient(135deg, #e67e22, #f39c12);
}

.qf-theme-orange .size-input-title {
    color: #f39c12;
}

.qf-theme-purple .quote-form-card {
    border-color: #9b59b6;
}

.qf-theme-purple .quote-form-header {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
}

.qf-theme-purple .size-input-title {
    color: #9b59b6;
}

.qf-theme-red .quote-form-card {
    border-color: #e74c3c;
}

.qf-theme-red .quote-form-header {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

.qf-theme-red .size-input-title {
    color: #e74c3c;
}

/* ====================================================
   2️⃣  CARDS & HEADERS
   ==================================================== */
.quote-form-card {
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid var(--qf-border);
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

@media (max-width: 768px) {
    .quote-form-card {
        border-radius: 10px;
        margin-bottom: 20px;
    }
}

.quote-form-header {
    background: linear-gradient(135deg, #0d6efd, #0099ff);
    padding: 15px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .quote-form-header {
        padding: 12px 15px;
    }
}

.quote-form-header h4,
.quote-form-header h5 {
    margin: 0;
    color: white;
    font-weight: 600;
}

.quote-form-header h4 {
    font-size: 1.5rem;
}

.quote-form-header h5 {
    font-size: 1.25rem;
}

@media (max-width: 768px) {
    .quote-form-header h4 {
        font-size: 1.2rem;
    }

    .quote-form-header h5 {
        font-size: 1.1rem;
    }
}

.quote-form-body {
    padding: 25px;
}

@media (max-width: 768px) {
    .quote-form-body {
        padding: 15px;
    }
}

/* ====================================================
   3️⃣  INPUT GROUPS & ROWS
   ==================================================== */
.quote-input-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .quote-input-row {
        flex-direction: column;
        gap: 15px;
    }
}

.quote-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.quote-input-group label {
    margin-bottom: 8px;
    color: var(--qf-text-muted);
    font-size: 0.9rem;
}

.quote-input-group input,
.quote-input-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--qf-border);
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.quote-input-group input:focus,
.quote-input-group select:focus {
    border-color: var(--qf-primary);
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.3);
    outline: none;
    background: rgba(255, 255, 255, 0.1);
}

/* ====================================================
   4️⃣  SIZE INPUT SECTION & TABS
   ==================================================== */
.size-input-section {
    background: linear-gradient(135deg, #2c3e50, #1a1a2e);
    /* Default Dark Blue */
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid var(--qf-border);
}

@media (max-width: 768px) {
    .size-input-section {
        padding: 15px;
    }
}

.size-input-title {
    font-size: 1.1rem;
    color: var(--qf-warning);
    margin-bottom: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.size-input-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.size-input-item {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.size-input-item label {
    margin-bottom: 8px;
    color: var(--qf-text-muted);
}

.size-input-item input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--qf-border);
    color: white;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

/* QF Tabs (Refined) */
.qf-tab-grid {
    display: grid;
    gap: 15px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.qf-tab {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--qf-border);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.qf-tab:hover,
.qf-tab.active,
.qf-tab.selected {
    background: rgba(13, 110, 253, 0.2);
    border-color: var(--qf-primary);
}

.qf-tab img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 5px;
}

.qf-tab .tab-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.qf-tab .tab-name {
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.qf-tab .tab-desc {
    font-size: 0.8rem;
    color: var(--qf-text-muted);
}

/* ====================================================
   5️⃣  MOTOR GRID / MOTOR CARD
   ==================================================== */
.motor-grid-container {
    margin-top: 20px;
    border-top: 1px solid var(--qf-border);
    padding-top: 20px;
}

.motor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

@media (max-width: 768px) {
    .motor-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.motor-card {
    background-color: var(--qf-bg-dark);
    border: 2px solid var(--qf-border);
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    height: 100%;
}

.motor-card:hover {
    border-color: var(--qf-primary);
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(13, 110, 253, 0.3);
}

.motor-card.selected {
    border-color: var(--qf-success);
    background-color: #1a3a2e;
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.4);
}

.motor-card.selected::before {
    content: "✓ เลือกแล้ว";
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--qf-success);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 10;
}

.motor-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.motor-card .motor-brand {
    font-size: 0.75rem;
    color: var(--qf-text-muted);
    margin-top: 8px;
    text-transform: uppercase;
}

.motor-card .motor-model {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    margin: 4px 0;
}

.motor-card .motor-capacity {
    font-size: 0.8rem;
    color: var(--qf-warning);
    margin-bottom: 4px;
}

.motor-card .motor-price {
    font-size: 1rem;
    color: var(--qf-primary);
    font-weight: bold;
    margin-bottom: 10px;
}

/* ====================================================
   6️⃣  WARNING BOX + RECOMMENDATION
   ==================================================== */
.recommendation-box {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid var(--qf-success);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
}

.recommendation-box.show {
    display: block;
    animation: qfFadeIn 0.3s ease;
}

.recommendation-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.area-display .area-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--qf-success);
}

.area-display .area-label {
    font-size: 0.8rem;
    color: var(--qf-text-muted);
}

.recommend-info .recommend-label {
    font-size: 1.1rem;
    color: white;
    font-weight: 600;
}

.recommend-info .recommend-hint {
    font-size: 0.9rem;
    color: var(--qf-text-muted);
}

.placeholder-msg {
    text-align: center;
    padding: 30px;
    color: var(--qf-text-muted);
    border: 2px dashed var(--qf-border);
    border-radius: 10px;
}

/* ====================================================
   7️⃣  ACCESSORY SECTION & GRID
   ==================================================== */
.accessory-section {
    margin-top: 30px;
}

.accessory-section-header {
    background: linear-gradient(135deg, #0d6efd, #0099ff);
    padding: 12px 20px;
    border-radius: 10px 10px 0 0;
}

.accessory-section-header h5 {
    margin: 0;
    color: white;
    font-size: 1rem;
}

.accessory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    padding: 20px;
    background: var(--qf-bg-card);
    border: 1px solid var(--qf-border);
    border-top: none;
    border-radius: 0 0 10px 10px;
}

@media (max-width: 768px) {
    .accessory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px;
    }
}

.accessory-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--qf-border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    /* Ensure label works as block */
}

.accessory-card:hover {
    border-color: var(--qf-primary);
    background: rgba(0, 0, 0, 0.4);
}

.accessory-card.selected {
    border-color: var(--qf-success);
    background: rgba(40, 167, 69, 0.2);
}

.accessory-card img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 4px;
}

.accessory-card .acc-name {
    font-size: 0.85rem;
    color: white;
    margin-bottom: 4px;
    line-height: 1.2;
}

.accessory-card .acc-price {
    font-size: 0.8rem;
    color: var(--qf-warning);
}

.acc-qty-wrap {
    margin: 5px 0;
}

.acc-qty-input {
    width: 50px;
    text-align: center;
    border-radius: 4px;
    border: 1px solid #555;
    background: #222;
    color: white;
    font-size: 0.8rem;
}

/* ====================================================
   8️⃣  SUBMIT SECTION
   ==================================================== */
.submit-section {
    text-align: center;
    margin-top: 40px;
    padding-bottom: 40px;
}

.submit-btn {
    background: linear-gradient(135deg, #28a745, #218838);
    color: white;
    border: none;
    padding: 15px 50px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(40, 167, 69, 0.4);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(40, 167, 69, 0.5);
    background: linear-gradient(135deg, #218838, #1e7e34);
}

.submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

.submit-hint {
    margin-top: 15px;
    color: #ffffff;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.submit-hint.ready {
    color: var(--qf-success);
    font-weight: 500;
}

/* ====================================================
   9️⃣  UTILITIES & ANIMATIONS
   ==================================================== */
@keyframes qfFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qf-panel {
    display: none;
    margin-top: 20px;
    animation: qfFadeIn 0.3s ease;
}

.qf-panel.show {
    display: block;
}

.qf-item-grid {
    display: grid;
    gap: 15px;
}

/* Extended Grid Support for Mirror/DoorLock */
.mr-spec-3 {
    grid-template-columns: repeat(3, 1fr);
}

.mr-spec-4 {
    grid-template-columns: repeat(4, 1fr);
}

.mr-spec-5 {
    grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 768px) {

    .mr-spec-3,
    .mr-spec-4,
    .mr-spec-5 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.qf-spec-row {
    display: grid;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.spec-item {
    display: flex;
    flex-direction: column;
}

.spec-item label {
    font-size: 0.8rem;
    color: #ccc;
    margin-bottom: 4px;
}

.spec-item input,
.spec-item select {
    background: #222;
    border: 1px solid #555;
    color: white;
    padding: 6px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Global Item Header Badge */
.item-header {
    background: #6c757d;
    color: #fff;
    font-size: .65rem;
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
    display: inline-block;
}

.item-header.red {
    background: #dc3545;
}

.item-header.blue {
    background: #3498db;
}

.item-header.green {
    background: #28a745;
}

.item-header.orange {
    background: #fd7e14;
}

/* QF Item (Generic Card) */
.qf-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--qf-border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
    position: relative;
}

.qf-item:hover {
    border-color: var(--qf-primary);
    background: rgba(0, 0, 0, 0.2);
}

.qf-item img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 6px;
}

.qf-item .item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    margin-bottom: 4px;
}

.qf-item .item-price {
    font-size: 0.85rem;
    color: var(--qf-warning);
}

.qf-calc-box {
    margin-top: 20px;
    padding: 20px;
    background: #1a1a2e;
    border: 2px solid var(--qf-primary);
    border-radius: 10px;
    text-align: center;
}

.calc-total {
    font-size: 2rem;
    color: var(--qf-primary);
    font-weight: bold;
}

.calc-detail {
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 5px;
}

/* Document Type Row */
.qf-doc-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}
.qf-theme-green .quote-form-card { border-color: #2ecc71; }
.qf-theme-green .quote-form-header { background: linear-gradient(135deg, #27ae60, #2ecc71); }
.qf-theme-green .size-input-title { color: #2ecc71; }

.qf-theme-blue .quote-form-card { border-color: #3498db; }
.qf-theme-blue .quote-form-header { background: linear-gradient(135deg, #2980b9, #3498db); }
.qf-theme-blue .size-input-title { color: #3498db; }

/* Refined Spec Row for Mirror.php */
.qf-spec-row {
    display: grid;
    gap: 10px;
    margin-top: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--qf-border);
    border-radius: 10px;
    align-items: end;
}
.spec-item label { 
    font-size: 0.85rem; 
    color: var(--qf-text-muted); 
    margin-bottom: 6px; 
    display: block; 
}
.spec-item input, .spec-item select {
    width: 100%;
    background: #1a1a2e;
    border: 1px solid var(--qf-border);
    color: white;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.95rem;
    text-align: center;
}
.spec-item input:focus, .spec-item select:focus {
    border-color: var(--qf-primary);
    outline: none;
}

/* Calc Row for Windproof.php */
.qf-calc-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
}
@media (max-width: 768px) {
    .qf-calc-row { grid-template-columns: 1fr; }
}
.qf-calc-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    border: 1px solid var(--qf-border);
}
.qf-calc-item .rl { font-size: 0.8rem; color: #adb5bd; margin-bottom: 5px; }
.qf-calc-item .rv { font-size: 1.2rem; font-weight: bold; color: white; margin-bottom: 2px; }
.qf-calc-item .rs { font-size: 0.75rem; color: #6c757d; }


/* Active State for Calc Item */
.qf-calc-item.active {
    background: rgba(40, 167, 69, 0.15);
    border-color: var(--qf-success);
}
.qf-calc-item.active .rv { color: var(--qf-success); }

/* Utilities for Panel Headers / Dividers */
.qf-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 20px 0;
    padding-top: 20px;
}
.qf-sub-header {
    font-size: 1.1rem;
    margin: 20px 0 12px;
    font-weight: 600;
}
.qf-sub-header.orange { color: #f39c12; }
.qf-sub-header.blue { color: #3498db; }
.qf-sub-header.red { color: #e74c3c; }
.qf-sub-header.purple { color: #9b59b6; }

