/**
 * Sales Man Dashboard Styles
 * Blue and orange theme with modern design
 */

/* Main Container */
.sales-man-dashboard {
    font-family: 'Kanit', 'Prompt', 'Sarabun', sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

/* Dashboard Header */
.sales-man-dashboard-header {
    margin-bottom: 20px;
}

.sales-man-dashboard-title {
    color: #1a3b6e; /* Blue theme color */
    font-size: 24px;
    margin-bottom: 15px;
    border-bottom: 2px solid #1a3b6e;
    padding-bottom: 10px;
}

/* Filters Section */
.sales-man-dashboard-filters {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.sales-man-dashboard-filter {
    flex: 1;
    min-width: 0; /* อนุญาตให้หดตัวได้ */
    padding: 10px 15px;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    background-color: white;
    color: #333;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.sales-man-dashboard-filter:focus {
    border-color: #1a3b6e;
    box-shadow: 0 0 0 2px rgba(26, 59, 110, 0.2);
    outline: none;
}

.sales-man-dashboard-button {
    flex: 0 0 auto; /* ไม่ขยายไม่หด */
    padding: 10px 20px;
    background-color: #f66c1f;
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(246, 108, 31, 0.3);
    white-space: nowrap; /* ป้องกันข้อความขึ้นบรรทัดใหม่ */
}

.sales-man-dashboard-button:hover {
    background-color: #e05b10;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(246, 108, 31, 0.4);
}

.sales-man-dashboard-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(246, 108, 31, 0.4);
}

/* Month Shortcuts */
.sales-man-dashboard-month-shortcuts {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.sales-man-dashboard-month-shortcuts button {
    width: 48px; /* เพิ่มขนาดจาก 36px */
    height: 48px; /* เพิ่มขนาดจาก 36px */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid #d1d1d1;
    background-color: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sales-man-dashboard-month-shortcuts button svg {
    width: 24px; /* เพิ่มขนาดไอคอน */
    height: 24px; /* เพิ่มขนาดไอคอน */
}

.sales-man-dashboard-month-shortcuts button:hover {
    background-color: #f0f0f0;
    color: #1a3b6e;
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

/* Document Type Items */
.sales-man-dashboard-doc-types {
    margin-bottom: 20px;
}

.sales-man-dashboard-section-title {
    font-size: 18px;
    color: #1a3b6e;
    margin-bottom: 10px;
}

.sales-man-dashboard-doc-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.sales-man-dashboard-doc-type-item {
    padding: 15px;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 4px solid transparent;
}

.sales-man-dashboard-doc-type-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.sales-man-dashboard-doc-type-item.active {
    background-color: #f5f9ff;
    border-left-width: 4px;
}

.sales-man-dashboard-doc-type-label {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
}

.sales-man-dashboard-doc-type-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
}

.sales-man-dashboard-doc-type-amount {
    font-size: 18px;
    font-weight: bold;
}

/* Results Title */
.sales-man-dashboard-results-title {
    color: #1a3b6e;
    font-size: 20px;
    margin: 25px 0 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

/* Results Table */
.sales-man-dashboard-results-table-container {
    overflow-x: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sales-man-dashboard-results-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.sales-man-dashboard-results-table th, 
.sales-man-dashboard-results-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.sales-man-dashboard-results-table th {
    background-color: #1a3b6e; /* Blue theme */
    color: white;
    font-weight: bold;
    position: sticky;
    top: 0;
    font-size: 15px;
}

.sales-man-dashboard-th-sub {
    font-size: 12px;
    font-weight: normal;
    opacity: 0.8;
}

.sales-man-dashboard-results-table th:first-child {
    border-top-left-radius: 6px;
}

.sales-man-dashboard-results-table th:last-child {
    border-top-right-radius: 6px;
}

.sales-man-dashboard-results-table tr:hover {
    background-color: #f5f9ff;
}

.sales-man-dashboard-totals-row {
    background-color: #f1f7ff;
    border-top: 2px solid #d0e0f5;
}

.sales-man-dashboard-amount {
    text-align: right;
    font-family: 'Sarabun', monospace;
}

.sales-man-dashboard-amount-value {
    font-weight: 500;
}

.sales-man-dashboard-amount-percent {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
}

.sales-man-dashboard-total {
    font-weight: bold;
    color: #1a3b6e;
}

.sales-man-dashboard-no-data {
    text-align: center;
    color: #888;
    padding: 30px 0;
    font-style: italic;
}

/* Note for daily average */
.sales-man-dashboard-note {
    font-style: italic;
    color: #666;
    margin-top: 15px;
    font-size: 14px;
    padding-left: 10px;
    border-left: 3px solid #f66c1f;
}

/* Error Message */
.sales-man-dashboard-error-message {
    background-color: #fff0f0;
    border-left: 4px solid #ff5252;
    padding: 15px 20px;
    color: #cc0000;
    margin: 20px 0;
    border-radius: 4px;
}

/* Skeleton Loading */
.sales-man-dashboard-skeleton {
    background-color: white;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sales-man-dashboard-skeleton-header {
    height: 30px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: sales-man-dashboard-skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 25px;
}

.sales-man-dashboard-skeleton-row {
    height: 20px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: sales-man-dashboard-skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 15px;
}

.sales-man-dashboard-skeleton-row:nth-child(odd) {
    opacity: 0.7;
}

@keyframes sales-man-dashboard-skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Loading state */
.sales-man-dashboard.loading .sales-man-dashboard-results {
    opacity: 0.5;
    pointer-events: none;
}

.sales-man-dashboard.loading .sales-man-dashboard-skeleton {
    display: block !important;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .sales-man-dashboard-filters {
        flex-wrap: wrap; /* อนุญาตให้ขึ้นบรรทัดใหม่เมื่อจำเป็น */
    }
    
    /* ให้ dropdown กว้างประมาณครึ่งหนึ่ง แสดง 2 อันต่อบรรทัด */
    .sales-man-dashboard-filter {
        flex: 1 0 calc(50% - 10px);
        min-width: calc(50% - 10px);
    }
    
    /* ปุ่มค้นหาอยู่บรรทัดเดียวกับ dropdown สุดท้าย */
    .sales-man-dashboard-button {
        flex: 0 0 auto;
    }
}

@media (max-width: 768px) {
    .sales-man-dashboard-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sales-man-dashboard-filter {
        width: 100%;
    }
    
    .sales-man-dashboard-button {
        width: 100%;
        margin-top: 10px;
    }
    
    .sales-man-dashboard-results-table th, 
    .sales-man-dashboard-results-table td {
        padding: 10px;
        font-size: 14px;
    }
    
    .sales-man-dashboard-title {
        font-size: 20px;
    }
    
    .sales-man-dashboard-month-shortcuts {
        margin-left: 0;
        margin-top: 10px;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .sales-man-dashboard-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sales-man-dashboard-filter {
        flex: 1 0 100%;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .sales-man-dashboard-button {
        width: 100%;
    }
    
    .sales-man-dashboard-month-shortcuts {
        margin: 10px auto 0;
        justify-content: center;
    }
}


/**
 * CSS สำหรับส่วนแสดงรายการที่ไม่ระบุผู้ขาย
 */

/* แถวที่ไม่ระบุผู้ขายในตารางหลัก */
.sales-man-dashboard-unspecified-row {
    background-color: #fffde7; /* สีเหลืองอ่อนๆ */
}

.sales-man-dashboard-unspecified-row:hover {
    background-color: #fff9c4;
}

/* ส่วนตารางรายการที่ไม่ระบุผู้ขาย */
.sales-man-dashboard-unspecified-section {
    margin-top: 30px;
    border-top: 1px dashed #ddd;
    padding-top: 20px;
}

.sales-man-dashboard-unspecified-table-container {
    overflow-x: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 15px;
}

.sales-man-dashboard-unspecified-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    font-size: 14px;
}

.sales-man-dashboard-unspecified-table th,
.sales-man-dashboard-unspecified-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.sales-man-dashboard-unspecified-table th {
    background-color: #fff8e1; /* สีพื้นหลังหัวตาราง */
    color: #b28704;
    font-weight: bold;
    position: sticky;
    top: 0;
    font-size: 14px;
    border-bottom: 2px solid #ffecb3;
}

.sales-man-dashboard-unspecified-table tr:hover {
    background-color: #fffde7;
}

.sales-man-dashboard-post-title {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* แบ่งประเภทเอกสาร */
.sales-man-dashboard-unspecified-table th:nth-child(4),
.sales-man-dashboard-unspecified-table th:nth-child(5),
.sales-man-dashboard-unspecified-table th:nth-child(6),
.sales-man-dashboard-unspecified-table th:nth-child(7) {
    color: #555;
    font-size: 13px;
    text-align: right;
}

.sales-man-dashboard-unspecified-table th:nth-child(4) { color: #00866F; } /* HS */
.sales-man-dashboard-unspecified-table th:nth-child(5) { color: #0066CC; } /* IV */
.sales-man-dashboard-unspecified-table th:nth-child(6) { color: #D14200; } /* HM */
.sales-man-dashboard-unspecified-table th:nth-child(7) { color: #FF9500; } /* NN */

/* โทนสีปุ่มกรองข้อมูล */
.sales-man-dashboard-filter option[value="unspecified"] {
    background-color: #fffde7;
    font-weight: bold;
    padding: 8px;
}

/* แสดง Popup เมื่อ Hover ชื่อรายการ */
.sales-man-dashboard-post-title {
    position: relative;
}

.sales-man-dashboard-post-title:hover::after {
    content: attr(title);
    position: absolute;
    left: 0;
    top: 100%;
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: normal;
    max-width: 250px;
    z-index: 100;
}