/* Categories Stock Additional Styles */
/* เสริมสไตล์ให้กับ stock_products.css */

\n/* Tab Navigation Styles */
.tab-section {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 2rem;
}

.tab-nav {
    display: flex;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 1rem 2rem;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 150px;
    justify-content: center;
}

.tab-btn:hover {
    color: #495057;
    background: rgba(102, 126, 234, 0.1);
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.tab-btn i {
    font-size: 13px;
}

/* Responsive Tab Navigation */
@media (max-width: 768px) {
    .tab-nav {
        padding: 0 1rem;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        min-width: 120px;
        font-size: 13px;
    }
    
    .tab-btn i {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .tab-nav {
        flex-direction: column;
        padding: 0;
    }
    
    .tab-btn {
        width: 100%;
        border-bottom: 1px solid #e9ecef;
        border-radius: 0;
        min-width: auto;
        padding: 1rem;
    }
    
    .tab-btn.active {
        border-bottom: 3px solid #667eea;
    }
}
/* Override Action Buttons ให้เล็กลง - มี !important เพื่อ override */
.products-table .action-buttons {
    display: flex !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
}

.products-table .action-buttons .btn-sm {
    min-width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    margin: 0 !important;
}

.products-table .action-buttons .btn-sm i {
    font-size: 11px !important;
    margin: 0 !important;
    line-height: 1 !important;
}

/* Modal Content เฉพาะสำหรับ Categories */
.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px; /* ลดขนาดให้เหมาะสมกับ categories form */
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal Header */
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Modal Body สำหรับ Categories */
.modal-body {
    padding: 2rem;
}

/* Form Grid สำหรับ Categories */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 คอลัมน์เท่ากัน */
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1; /* ขยายเต็มความกว้าง */
}

/* Labels */
.form-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    margin-bottom: 0.5rem;
}

/* Input Fields */
.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    color: #495057;
    background: white;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Textarea สำหรับคำอธิบาย */
.form-group textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 120px; /* จำกัดความสูงสูงสุด */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    overflow-y: auto;
    word-wrap: break-word;
}

/* Select Dropdown */
.form-group select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px;
    appearance: none;
    padding-right: 35px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
    margin-top: 1rem;
}

/* Button Improvements */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    min-width: 100px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Form Validation States */
.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-group .error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-group .error-message i {
    font-size: 10px;
}

/* Success States */
.form-group input.success,
.form-group select.success,
.form-group textarea.success {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

/* Loading Button State */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 85vh;
    }

    .modal-body {
        padding: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr; /* 1 คอลัมน์ใน mobile */
        gap: 1rem;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .modal-header {
        padding: 1rem 1.5rem;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-header {
        border-radius: 0;
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px;
        font-size: 14px;
    }

    .form-group textarea {
        min-height: 60px;
        max-height: 100px;
    }
}

/* เพิ่มสไตล์สำหรับ View Modal */
.product-details {
    padding: 0; /* ให้ padding อยู่ใน div ข้างใน */
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-label {
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.detail-value {
    font-size: 1rem;
    color: #333;
    word-wrap: break-word;
}

/* Status Badge ใน View Modal */
.detail-value .status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    min-width: 75px;
    text-align: center;
}

/* Action Buttons - ปรับขนาดให้เล็กลงและสวยขึ้น */
.action-buttons {
    display: flex;
    gap: 4px; /* ลดระยะห่าง */
    flex-wrap: nowrap; /* ไม่ให้ wrap */
    justify-content: center;
    align-items: center;
}

.action-buttons .btn-sm {
    min-width: 28px; /* ลดขนาด */
    height: 28px; /* ลดขนาด */
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px; /* ลดมุมโค้ง */
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px; /* ลดขนาด font */
    font-weight: 500;
}

.action-buttons .btn-sm i {
    font-size: 11px; /* ลดขนาด icon */
    margin: 0;
}

/* ปรับสีและ hover effects */
.action-buttons .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-buttons .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.action-buttons .btn-secondary {
    background: #6c757d;
    color: white;
}

.action-buttons .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.action-buttons .btn-danger {
    background: #dc3545;
    color: white;
}

.action-buttons .btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

/* ปรับขนาดคอลัมน์จัดการ */
.products-table th:last-child,
.products-table td:last-child {
    width: 120px; /* กำหนดความกว้างคงที่ */
    text-align: center;
    vertical-align: middle;
    padding: 8px 4px; /* ลด padding */
}

/* Responsive สำหรับ Action Buttons */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        gap: 3px;
        align-items: stretch;
    }
    
    .action-buttons .btn-sm {
        width: 100%;
        min-width: 32px;
        height: 26px;
        font-size: 10px;
    }
    
    .action-buttons .btn-sm i {
        font-size: 10px;
    }
    
    .products-table th:last-child,
    .products-table td:last-child {
        width: 80px;
        padding: 6px 2px;
    }
}

@media (max-width: 480px) {
    .action-buttons {
        gap: 2px;
    }
    
    .action-buttons .btn-sm {
        height: 24px;
        font-size: 9px;
        border-radius: 4px;
    }
    
    .action-buttons .btn-sm i {
        font-size: 9px;
    }
    
    .products-table th:last-child,
    .products-table td:last-child {
        width: 70px;
        padding: 4px 2px;
    }
}

/* Hide scrollbar สำหรับ textarea แต่ยังสามารถ scroll ได้ */
.form-group textarea::-webkit-scrollbar {
    width: 6px;
}

.form-group textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.form-group textarea::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.form-group textarea::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}