/* Responsive Design for PeakTabien.com */

/* Base Reset for Responsive */
body {
    min-width: auto !important;
    overflow-x: hidden !important;
}

.container {
    width: 100% !important;
    max-width: 1400px !important; /* เพิ่มจาก 1200px เป็น 1400px */
    margin: 0 auto !important;
    padding: 0 0px !important; /* เปลี่ยนจาก 10px เป็น 0px เพื่อให้รูปภาพชิดขอบจอ */
}

/* Header Responsive - Maintain structure as requested */
.top-header {
    width: 100% !important;
    padding: 5px 0 !important;
}

@media (max-width: 768px) {
    .top-header {
        padding: 10px 0 !important; /* เพิ่ม Padding 10% (โดยประมาณ) เพื่อขยายความสูง Header */
    }
    
    .contact-item {
        height: clamp(35px, 8vw, 55px) !important; /* ขยายความสูง Contact Item ขึ้นประมาณ 20-30% */
        padding: 4px 12px !important; /* เพิ่ม Padding ภายใน */
        font-size: clamp(0.75rem, 2.2vw, 1.6rem) !important; /* ขยายขนาดตัวอักษร */
    }
    
    .contact-icon {
        width: clamp(22px, 4vw, 42px) !important; /* ขยายขนาดไอคอน */
        height: clamp(22px, 4vw, 42px) !important;
    }
}

.header-container {
    width: 98% !important;
    gap: 8px !important;
    flex-wrap: nowrap !important; /* Keep logo and content side by side */
}

.logo-box {
    padding: 2px !important;
}

.logo-image {
    height: clamp(50px, 12vw, 120px) !important;
    width: auto !important;
}

.content-box {
    padding: 2px 0 !important;
}

.website-name {
    font-size: clamp(1rem, 4.5vw, 4.5rem) !important;
    white-space: nowrap !important;
}

.contact-row {
    gap: 5px !important;
    flex-wrap: nowrap !important; /* Keep contacts in one line */
    overflow-x: auto !important; /* Allow scrolling if too wide on very small screens */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    justify-content: flex-start !important;
}

.contact-row::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari and Opera */
}

.contact-item {
    padding: 2px 8px !important;
    font-size: clamp(0.6rem, 1.8vw, 1.4rem) !important;
    gap: 4px !important;
    height: clamp(25px, 6vw, 45px) !important;
}

.contact-icon {
    width: clamp(18px, 3vw, 35px) !important;
    height: clamp(18px, 3vw, 35px) !important;
    border-radius: 50% !important;
}

.admin-icon {
    border-radius: 50% !important;
    object-fit: cover !important;
}

/* Search Section Responsive */
.search-filters, .search-buttons {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 8px !important;
}

.search-input {
    font-size: 1rem !important;
}

.filter-select, .btn {
    font-size: 0.9rem !important;
    padding: 8px 15px !important;
    min-width: 120px !important;
}

/* Grid Layout Responsive */
.data-table {
    display: grid !important;
    gap: 5px !important;
    padding: 5px !important;
}

.table-row {
    display: contents !important; /* ทำให้ลูกของ .table-row กลายเป็นลูกของ .data-table โดยตรงในแง่ของ Grid */
}

.table-cell {
    border: none !important;
    padding: 0 !important;
    min-height: auto !important;
    background: none !important;
    display: block !important;
}

.license-plate {
    width: 100% !important;
    margin: 0 !important;
    padding: 5px !important;
    min-height: 80px !important;
}

.license-text {
    font-family: 'Peaktabien', 'Kanit', sans-serif !important;
    font-size: 1.2rem !important;
    font-weight: 900 !important; /* เพิ่มความหนา */
    margin-top: 2px !important;
    margin-bottom: 0 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    letter-spacing: -0.5px !important; /* ปรับระยะห่าง */
    text-shadow: 0.5px 0.5px 0px #ffffff, 1px 1px 1px rgba(0,0,0,0.3) !important; /* เพิ่มแสงเงาขนาดเล็ก */
}

.license-price {
    font-size: 0.9rem !important;
}

.license-badge {
    width: 28px !important;
    height: 28px !important;
    font-size: 16px !important;
}

/* Media Queries for Grid */

/* Desktop: 7 Grid (min-width: 1025px) */
@media (min-width: 1025px) {
    .data-table {
        grid-template-columns: repeat(7, 1fr) !important;
    }
    .license-text { 
        font-size: 2.2rem !important; 
        font-weight: 900 !important;
        letter-spacing: -1px !important;
        margin-bottom: 5px !important;
        text-shadow: none !important;
    }
    .license-price { 
        font-size: 1.2rem !important;
        position: relative !important;
        bottom: auto !important;
        width: 100% !important;
        margin-top: 5px !important;
    }
}

/* Tablet: 5 Grid (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .data-table {
        grid-template-columns: repeat(5, 1fr) !important;
    }
    .license-text { 
        font-size: 2.0rem !important; 
        font-weight: 900 !important;
        letter-spacing: -1px !important;
        margin-bottom: 5px !important;
        text-shadow: none !important;
    }
    .license-price { 
        font-size: 1.0rem !important;
        position: relative !important;
        bottom: auto !important;
        width: 100% !important;
        margin-top: 5px !important;
    }
    .license-badge {
        width: 24px !important;
        height: 24px !important;
        font-size: 14px !important;
    }
}

/* Mobile: 4 Grid (max-width: 768px) */
@media (max-width: 768px) {
    .table-header {
        margin-bottom: 4px !important;
    }
    .table-header h3 {
        font-size: 1.35rem !important;
        padding: 3.75px 0 !important;
        line-height: 1.2 !important;
    }
    .data-section {
        padding: 2px 5px !important;
    }
    .data-table {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2px !important;
        padding: 2px !important;
    }
    .license-plate {
        min-height: 60px !important;
        padding: 2px !important;
        border-width: 1.5px !important;
        border-radius: 6px !important;
    }
    .license-text { 
        font-size: 1.6rem !important; 
        font-weight: 900 !important;
        margin-top: 0px !important;
        margin-bottom: 4px !important;
        letter-spacing: -1px !important;
        text-shadow: none !important;
    }
    .license-price { 
        font-size: 0.85rem !important;
        position: relative !important;
        bottom: auto !important;
        width: 100% !important;
        margin-top: 4px !important;
    }
    
    /* แก้ไขปัญหาการแสดงผลรวมซ้ำซ้อน: ซ่อน .license-sum-badge และใช้เฉพาะ .license-badge (สีฟ้า) */
    .license-sum-badge {
        display: none !important;
    }
    
    .license-badge {
        display: flex !important; /* บังคับให้แสดงเฉพาะอันนี้ */
        width: 20px !important;
        height: 20px !important;
        font-size: 11px !important;
        bottom: 2px !important;
        right: 2px !important;
        border-width: 1px !important;
        background-color: #1877f2 !important; /* สีฟ้าตามที่ระบุ */
        color: white !important;
        justify-content: center;
        align-items: center;
        position: absolute;
        border-radius: 50%;
    }
    
    /* .logo-image { height: 40px !important; margin-right: 6px !important; } */
    /* .contact-details-single-line { flex-direction: row !important; } */
    /* .contact-item { font-size: 1.1rem !important; padding: 3px 8px !important; } */
}

/* Extra Small Mobile: 4 Grid (max-width: 480px) */
@media (max-width: 480px) {
    .table-header h3 {
        font-size: 1.1rem !important; /* ปรับลดลงอีกสำหรับหน้าจอเล็กมาก */
    }
    /* .main-logo { font-size: 1.1rem !important; } */
    /* .logo-image { height: 32px !important; margin-right: 5px !important; } */
    .data-table {
        grid-template-columns: repeat(4, 1fr) !important; /* คงไว้ 4 คอลัมน์แม้บนหน้าจอเล็กมาก */
        gap: 1px !important; /* ลดช่องว่างให้เหลือน้อยที่สุด */
        padding: 1px !important;
    }
    .license-plate {
        padding: 1px !important;
        min-height: 50px !important; /* ลดความสูงลงอีกสำหรับหน้าจอเล็กมาก */
        border-width: 1px !important;
    }
    .license-text { 
        font-size: 1.2rem !important; 
        letter-spacing: -1px !important;
        margin-bottom: 3px !important;
        gap: 0px !important;
        text-shadow: none !important;
    }
    .license-text .thai-consonant,
    .license-text .number {
        font-size: 1.1em !important;
        letter-spacing: -0.05em !important;
    }
    .license-price { 
        font-size: 0.75rem !important;
        position: relative !important;
        bottom: auto !important;
        width: 100% !important;
        margin-top: 3px !important;
    }
    
    /* แก้ไขปัญหาการแสดงผลรวมซ้ำซ้อนบนหน้าจอเล็กมาก */
    .license-sum-badge {
        display: none !important;
    }
    
    .license-badge {
        display: flex !important;
        width: 18px !important;
        height: 18px !important;
        font-size: 10px !important;
        bottom: 1px !important;
        right: 1px !important;
        border-width: 1px !important;
        background-color: #1877f2 !important;
    }
}

/* Search Section 4 Rows Layout */
.search-container-box {
    background: #f9f9f9 !important;
    padding: 5px 5px !important; /* ลด padding ลงเพื่อให้สอดคล้องกับ .search-section padding 2px */
    border-radius: 10px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    max-width: 1400px !important; /* ปรับให้เท่ากับ container หลัก (1400px) */
    margin: 0 auto !important;
    width: 100% !important;
}

.search-row {
    display: flex !important;
    gap: 10px !important;
    margin-bottom: 8px !important;
    width: 100% !important;
}

.search-row:last-child {
    margin-bottom: 0 !important;
}

.search-row .search-input-container,
.search-row .filter-select,
.search-row .search-buttons {
    width: 100% !important;
    margin: 0 !important;
}

/* ปรับแต่งปุ่มในแถวที่ 4 ให้สมดุล */
.row-4 .search-buttons {
    display: flex !important;
    gap: 15px !important;
    justify-content: center !important;
}

.row-4 .btn {
    max-width: initial !important;
}

/* Row 1: Full width search input */
.row-1 .search-input-container {
    flex: 1 !important;
}

.row-1 .search-input {
    width: 100% !important;
    padding: 12px 15px !important;
    border: 1px solid #ddd !important;
    border-radius: 5px !important;
    font-size: 1rem !important;
}

/* Row 2: Half width price and sum filters */
.row-2 .filter-select {
    flex: 1 !important;
}

/* Row 3: Full width category filter */
.row-3 .filter-select {
    flex: 1 !important;
}

/* Row 4: Half width buttons */
.row-4 .search-buttons {
    display: flex !important;
    gap: 10px !important;
    width: 100% !important;
}

.row-4 .btn {
    flex: 1 !important;
    width: 100% !important;
    padding: 12px !important;
    font-size: 1rem !important;
    border-radius: 5px !important;
    cursor: pointer !important;
    border: none !important;
    font-weight: 500 !important;
}

.row-4 .btn-home {
    background-color: #28a745 !important;
    color: white !important;
}

.row-4 .btn-upload {
    background-color: #1877f2 !important;
    color: white !important;
}

/* Responsive adjustments for Search Section */
@media (max-width: 768px) {
    .search-container-box {
        padding: 2px !important;
    }
    
    .search-row {
        gap: 8px !important;
        margin-bottom: 10px !important;
    }
    
    .row-1 .search-input,
    .filter-select,
    .row-4 .btn {
        font-size: 0.9rem !important;
        padding: 10px !important;
    }
}
